2015-03-09 17:07:08 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
|
|
2016-03-06 15:51:06 +00:00
|
|
|
uBlock Origin - a browser extension to block requests.
|
2019-09-17 19:15:01 +00:00
|
|
|
Copyright (C) 2015-present Raymond Hill
|
2015-03-09 17:07:08 +00:00
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
|
|
|
|
|
|
|
|
|
Home: https://github.com/gorhill/uBlock
|
|
|
|
|
*/
|
|
|
|
|
|
2017-01-22 21:05:16 +00:00
|
|
|
/* global HTMLDocument */
|
2015-03-09 17:07:08 +00:00
|
|
|
|
2017-01-18 18:17:47 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
2015-03-09 17:07:08 +00:00
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
// Injected into specific web pages, those which have been pre-selected
|
|
|
|
|
// because they are known to contains `abp:subscribe` links.
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2019-09-17 19:15:01 +00:00
|
|
|
(( ) => {
|
2020-09-13 12:01:53 +00:00
|
|
|
// >>>>> start of local scope
|
2015-03-09 17:07:08 +00:00
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2015-04-07 01:26:05 +00:00
|
|
|
// https://github.com/chrisaljoudi/uBlock/issues/464
|
2020-09-13 12:01:53 +00:00
|
|
|
if ( document instanceof HTMLDocument === false ) { return; }
|
2015-03-09 17:07:08 +00:00
|
|
|
|
2020-09-13 12:01:53 +00:00
|
|
|
// Maybe uBO has gone away meanwhile.
|
|
|
|
|
if ( typeof vAPI !== 'object' || vAPI === null ) { return; }
|
2015-03-09 17:07:08 +00:00
|
|
|
|
2020-09-13 12:01:53 +00:00
|
|
|
// https://github.com/easylist/EasyListHebrew/issues/89
|
|
|
|
|
// Ensure trusted events only.
|
2019-09-17 19:15:01 +00:00
|
|
|
|
2020-09-13 12:01:53 +00:00
|
|
|
const onMaybeSubscriptionLinkClicked = function(ev) {
|
|
|
|
|
if ( ev.button !== 0 || ev.isTrusted === false ) { return; }
|
2019-09-17 19:15:01 +00:00
|
|
|
|
2020-09-13 12:01:53 +00:00
|
|
|
const target = ev.target.closest('a');
|
|
|
|
|
if ( target instanceof HTMLAnchorElement === false ) { return; }
|
2019-09-17 19:15:01 +00:00
|
|
|
|
2020-09-13 12:01:53 +00:00
|
|
|
if ( vAPI instanceof Object === false ) {
|
|
|
|
|
document.removeEventListener('click', onMaybeSubscriptionLinkClicked);
|
2016-03-17 14:32:11 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2019-09-17 19:15:01 +00:00
|
|
|
|
|
|
|
|
const href = target.href || '';
|
2020-09-13 12:01:53 +00:00
|
|
|
const matches = /^(?:abp|ubo):\/*subscribe\/*\?location=([^&]+).*title=([^&]+)/.exec(href);
|
|
|
|
|
if ( matches === null ) { return; }
|
2019-09-17 19:15:01 +00:00
|
|
|
|
2020-09-13 12:01:53 +00:00
|
|
|
vAPI.messaging.send('scriptlets', {
|
|
|
|
|
what: 'subscribeTo',
|
|
|
|
|
location: decodeURIComponent(matches[1]),
|
|
|
|
|
title: decodeURIComponent(matches[2]),
|
|
|
|
|
});
|
2015-03-09 17:07:08 +00:00
|
|
|
|
|
|
|
|
ev.stopPropagation();
|
|
|
|
|
ev.preventDefault();
|
|
|
|
|
};
|
|
|
|
|
|
2020-09-13 12:01:53 +00:00
|
|
|
document.addEventListener('click', onMaybeSubscriptionLinkClicked);
|
2015-03-09 17:07:08 +00:00
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2020-09-13 12:01:53 +00:00
|
|
|
// <<<<< end of local scope
|
2015-03-09 17:07:08 +00:00
|
|
|
})();
|
|
|
|
|
|
2018-05-03 13:55:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
|
|
|
|
|
|
DO NOT:
|
|
|
|
|
- Remove the following code
|
|
|
|
|
- Add code beyond the following code
|
|
|
|
|
Reason:
|
|
|
|
|
- https://github.com/gorhill/uBlock/pull/3721
|
|
|
|
|
- uBO never uses the return value from injected content scripts
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
void 0;
|