1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-05 18:32:30 +01:00

Fix breaking navigation through links [regression]

Regression from:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1797
This commit is contained in:
Raymond Hill 2021-11-04 11:48:07 -04:00
parent c25cfd2116
commit b63415a3db
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -61,14 +61,15 @@ const onMaybeSubscriptionLinkClicked = function(target) {
}
const location = subscribeURL.searchParams.get('location') || '';
const title = subscribeURL.searchParams.get('title') || '';
if ( location === '' || title === '' ) { return; }
if ( location === '' || title === '' ) { return true; }
// https://github.com/uBlockOrigin/uBlock-issues/issues/1797
if ( /^(file|https?):\/\//.test(location) === false ) { return; }
if ( /^(file|https?):\/\//.test(location) === false ) { return true; }
vAPI.messaging.send('scriptlets', {
what: 'subscribeTo',
location,
title,
});
return true;
} catch (_) {
}
};
@ -80,9 +81,10 @@ document.addEventListener('click', ev => {
if ( ev.button !== 0 || ev.isTrusted === false ) { return; }
const target = ev.target.closest('a');
if ( target instanceof HTMLAnchorElement === false ) { return; }
onMaybeSubscriptionLinkClicked(target);
ev.stopPropagation();
ev.preventDefault();
if ( onMaybeSubscriptionLinkClicked(target) === true ) {
ev.stopPropagation();
ev.preventDefault();
}
});
/******************************************************************************/