mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
parent
97a1765b6c
commit
c6aefbbed3
|
@ -131,10 +131,10 @@ QString Scripts::setupFormObserver()
|
||||||
" registerForm(document.forms[i]);"
|
" registerForm(document.forms[i]);"
|
||||||
""
|
""
|
||||||
"var observer = new MutationObserver(function(mutations) {"
|
"var observer = new MutationObserver(function(mutations) {"
|
||||||
" for (var i = 0; i < mutations.length; ++i)"
|
" for (var mutation of mutations)"
|
||||||
" for (var j = 0; j < mutations[i].addedNodes.length; ++j)"
|
" for (var node of mutation.addedNodes)"
|
||||||
" if (mutations[i].addedNodes[j].tagName == 'FORM')"
|
" if (node.tagName && node.tagName.toLowerCase() == 'form')"
|
||||||
" registerForm(mutations[i].addedNodes[j]);"
|
" registerForm(node);"
|
||||||
"});"
|
"});"
|
||||||
"observer.observe(document.documentElement, { childList: true, subtree: true });"
|
"observer.observe(document.documentElement, { childList: true, subtree: true });"
|
||||||
""
|
""
|
||||||
|
@ -303,11 +303,11 @@ QString Scripts::getFormData(const QPointF &pos)
|
||||||
{
|
{
|
||||||
QString source = QL1S("(function() {"
|
QString source = QL1S("(function() {"
|
||||||
"var e = document.elementFromPoint(%1, %2);"
|
"var e = document.elementFromPoint(%1, %2);"
|
||||||
"if (!e || e.tagName != 'INPUT')"
|
"if (!e || e.tagName.toLowerCase() != 'input')"
|
||||||
" return;"
|
" return;"
|
||||||
"var fe = e.parentElement;"
|
"var fe = e.parentElement;"
|
||||||
"while (fe) {"
|
"while (fe) {"
|
||||||
" if (fe.tagName == 'FORM')"
|
" if (fe.tagName.toLowerCase() == 'form')"
|
||||||
" break;"
|
" break;"
|
||||||
" fe = fe.parentElement;"
|
" fe = fe.parentElement;"
|
||||||
"}"
|
"}"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* Falkon - Qt web browser
|
* Falkon - Qt web browser
|
||||||
* Copyright (C) 2015-2017 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2015-2018 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -33,12 +33,12 @@ WebHitTestResult::WebHitTestResult(const WebPage *page, const QPoint &pos)
|
||||||
"if (!e)"
|
"if (!e)"
|
||||||
" return;"
|
" return;"
|
||||||
"function isMediaElement(e) {"
|
"function isMediaElement(e) {"
|
||||||
" return e.tagName == 'AUDIO' || e.tagName == 'VIDEO';"
|
" return e.tagName.toLowerCase() == 'audio' || e.tagName.toLowerCase() == 'video';"
|
||||||
"}"
|
"}"
|
||||||
"function isEditableElement(e) {"
|
"function isEditableElement(e) {"
|
||||||
" if (e.isContentEditable)"
|
" if (e.isContentEditable)"
|
||||||
" return true;"
|
" return true;"
|
||||||
" if (e.tagName == 'INPUT' || e.tagName == 'TEXTAREA')"
|
" if (e.tagName.toLowerCase() == 'input' || e.tagName.toLowerCase() == 'textarea')"
|
||||||
" return e.getAttribute('readonly') != 'readonly';"
|
" return e.getAttribute('readonly') != 'readonly';"
|
||||||
" return false;"
|
" return false;"
|
||||||
"}"
|
"}"
|
||||||
|
@ -62,16 +62,16 @@ WebHitTestResult::WebHitTestResult(const WebPage *page, const QPoint &pos)
|
||||||
"};"
|
"};"
|
||||||
"var r = e.getBoundingClientRect();"
|
"var r = e.getBoundingClientRect();"
|
||||||
"res.boundingRect = [r.top, r.left, r.width, r.height];"
|
"res.boundingRect = [r.top, r.left, r.width, r.height];"
|
||||||
"if (e.tagName == 'IMG')"
|
"if (e.tagName.toLowerCase() == 'img')"
|
||||||
" res.imageUrl = e.getAttribute('src');"
|
" res.imageUrl = e.getAttribute('src');"
|
||||||
"if (e.tagName == 'A') {"
|
"if (e.tagName.toLowerCase() == 'a') {"
|
||||||
" res.linkTitle = e.text;"
|
" res.linkTitle = e.text;"
|
||||||
" res.linkUrl = e.getAttribute('href');"
|
" res.linkUrl = e.getAttribute('href');"
|
||||||
"}"
|
"}"
|
||||||
"while (e) {"
|
"while (e) {"
|
||||||
" if (res.linkTitle == '' && e.tagName == 'A')"
|
" if (res.linkTitle == '' && e.tagName.toLowerCase() == 'a')"
|
||||||
" res.linkTitle = e.text;"
|
" res.linkTitle = e.text;"
|
||||||
" if (res.linkUrl == '' && e.tagName == 'A')"
|
" if (res.linkUrl == '' && e.tagName.toLowerCase() == 'a')"
|
||||||
" res.linkUrl = e.getAttribute('href');"
|
" res.linkUrl = e.getAttribute('href');"
|
||||||
" if (res.mediaUrl == '' && isMediaElement(e)) {"
|
" if (res.mediaUrl == '' && isMediaElement(e)) {"
|
||||||
" res.mediaUrl = e.currentSrc;"
|
" res.mediaUrl = e.currentSrc;"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user