1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-06 19:02:30 +01:00

Fix looking up clickable URLs in code viewer

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2759
This commit is contained in:
Raymond Hill 2023-07-29 10:51:15 -04:00
parent 81b2fcee5d
commit 223e230e49
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -284,7 +284,25 @@ async function start() {
}); });
dom.on('#content', 'click', '.cm-href', ev => { dom.on('#content', 'click', '.cm-href', ev => {
setURL(ev.target.textContent); const target = ev.target;
const urlParts = [ target.textContent ];
let previous = target;
for (;;) {
previous = previous.previousSibling;
if ( previous === null ) { break; }
if ( previous.nodeType !== 1 ) { break; }
if ( previous.classList.contains('cm-href') === false ) { break; }
urlParts.unshift(previous.textContent);
}
let next = target;
for (;;) {
next = next.nextSibling;
if ( next === null ) { break; }
if ( next.nodeType !== 1 ) { break; }
if ( next.classList.contains('cm-href') === false ) { break; }
urlParts.push(next.textContent);
}
setURL(urlParts.join(''));
}); });
} }