mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +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:
parent
81b2fcee5d
commit
223e230e49
1 changed files with 19 additions and 1 deletions
|
@ -284,7 +284,25 @@ async function start() {
|
|||
});
|
||||
|
||||
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(''));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue