Skip to content

Commit

Permalink
Update searchJumper.user.js
Browse files Browse the repository at this point in the history
  • Loading branch information
hoothin committed Sep 11, 2024
1 parent 62e57d8 commit a268853
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions searchJumper.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -1430,28 +1430,32 @@
}
}

function inputActive(doc) {
let activeEl = getActiveElement(doc);
if (activeEl &&
((/INPUT|TEXTAREA/i.test(activeEl.nodeName) &&
activeEl.getAttribute("aria-readonly") != "true"
function isInput(ele) {
if (ele &&
((/INPUT|TEXTAREA/i.test(ele.nodeName) &&
ele.getAttribute("aria-readonly") != "true"
) ||
activeEl.contentEditable == 'true'
ele.contentEditable == 'true'
)
) {
return true;
} else {
while (activeEl && activeEl.nodeName) {
if (activeEl.contentEditable == 'true') return true;
if (activeEl.nodeName.toUpperCase() == 'BODY') {
while (ele && ele.nodeName) {
if (ele.contentEditable == 'true') return true;
if (ele.nodeName.toUpperCase() == 'BODY') {
break;
}
activeEl = activeEl.parentNode;
ele = ele.parentNode;
}
}
return false;
}

function inputActive(doc) {
let activeEl = getActiveElement(doc);
return isInput(activeEl);
}

async function waitForFontAwesome(callback) {
while (document.hidden) {
await sleep(500);
Expand Down Expand Up @@ -8993,6 +8997,12 @@
if (searchData.prefConfig.minSizeMode) {
self.bar.classList.remove("minSizeModeClose");
}

let targetInput = false;
if (targetElement) {
targetInput = isInput(targetElement);
}

let href = targetElement && (targetElement.href || targetElement.src);
let keyWords = getKeywords();
shownSitesNum = 0;
Expand All @@ -9009,10 +9019,7 @@
pass = self.checkKwFilter(data.kwFilter, checkKw);
}
if (pass && se.dataset.paste) {
pass = targetElement &&
((/INPUT|TEXTAREA/i.test(targetElement.nodeName) &&
targetElement.getAttribute("aria-readonly") != "true") ||
targetElement.contentEditable == 'true');
pass = targetInput;
taggleHide(se, pass);
} else if (data.kwFilter) {
taggleHide(se, pass);
Expand Down Expand Up @@ -13042,6 +13049,7 @@
} else {
const selection = window.getSelection();
const range = selection.getRangeAt(0);
range.selectNode(element);
range.deleteContents();
range.insertNode(document.createTextNode(value));
selection.removeAllRanges();
Expand Down

0 comments on commit a268853

Please sign in to comment.