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:
parent
81b2fcee5d
commit
223e230e49
@ -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(''));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user