1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-24 03:12:46 +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 location = subscribeURL.searchParams.get('location') || '';
const title = subscribeURL.searchParams.get('title') || ''; const title = subscribeURL.searchParams.get('title') || '';
if ( location === '' || title === '' ) { return; } if ( location === '' || title === '' ) { return true; }
// https://github.com/uBlockOrigin/uBlock-issues/issues/1797 // 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', { vAPI.messaging.send('scriptlets', {
what: 'subscribeTo', what: 'subscribeTo',
location, location,
title, title,
}); });
return true;
} catch (_) { } catch (_) {
} }
}; };
@ -80,9 +81,10 @@ document.addEventListener('click', ev => {
if ( ev.button !== 0 || ev.isTrusted === false ) { return; } if ( ev.button !== 0 || ev.isTrusted === false ) { return; }
const target = ev.target.closest('a'); const target = ev.target.closest('a');
if ( target instanceof HTMLAnchorElement === false ) { return; } if ( target instanceof HTMLAnchorElement === false ) { return; }
onMaybeSubscriptionLinkClicked(target); if ( onMaybeSubscriptionLinkClicked(target) === true ) {
ev.stopPropagation(); ev.stopPropagation();
ev.preventDefault(); ev.preventDefault();
}
}); });
/******************************************************************************/ /******************************************************************************/