-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to update lists through links with specifically crafted URLs
As per discussion with uBO volunteers. Volunteers offering support for uBO will be able to craft links with specially formed URLs, which once clicked will cause uBO to automatically force an update of specified filter lists. The URL must be crafted as shown in the example below: https://ublockorigin.github.io/uAssets/update-lists.html?listkeys=ublock-filters,easylist Where the `listkeys` parameter is a comma-separated list of tokens corresponding to filter lists. If a token does not match an enabled filter list, it will be ignored. The ability to update filter lists through a specially crafted link is available only on uBO's own support sites: - https://github.com/uBlockOrigin/ - https://reddit.com/r/uBlockOrigin/ - https://ublockorigin.github.io/ Additionally, a visual cue has been added in the "Filter lists" pane to easily spot the filter lists which have been recently updated, where "recently" is currently defined as less than an hour ago.
- Loading branch information
Showing
7 changed files
with
152 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/******************************************************************************* | ||
uBlock Origin - a browser extension to block requests. | ||
Copyright (C) 2014-present Raymond Hill | ||
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 | ||
*/ | ||
|
||
/* global HTMLDocument */ | ||
|
||
'use strict'; | ||
|
||
/******************************************************************************/ | ||
|
||
// Injected into specific webpages, those which have been pre-selected | ||
// because they are known to contain `https://ublockorigin.github.io/update-lists?` links. | ||
|
||
/******************************************************************************/ | ||
|
||
(( ) => { | ||
// >>>>> start of local scope | ||
|
||
/******************************************************************************/ | ||
|
||
if ( document instanceof HTMLDocument === false ) { return; } | ||
|
||
// Maybe uBO has gone away meanwhile. | ||
if ( typeof vAPI !== 'object' || vAPI === null ) { return; } | ||
|
||
function updateStockLists(target) { | ||
if ( vAPI instanceof Object === false ) { | ||
document.removeEventListener('click', updateStockLists); | ||
return; | ||
} | ||
try { | ||
const updateURL = new URL(target.href); | ||
if ( updateURL.hostname !== 'ublockorigin.github.io') { return; } | ||
if ( updateURL.pathname !== '/uAssets/update-lists.html') { return; } | ||
const listkeys = updateURL.searchParams.get('listkeys') || ''; | ||
if ( listkeys === '' ) { return true; } | ||
vAPI.messaging.send('scriptlets', { | ||
what: 'updateLists', | ||
listkeys, | ||
}); | ||
return true; | ||
} catch (_) { | ||
} | ||
} | ||
|
||
// https://github.com/easylist/EasyListHebrew/issues/89 | ||
// Ensure trusted events only. | ||
|
||
document.addEventListener('click', ev => { | ||
if ( ev.button !== 0 || ev.isTrusted === false ) { return; } | ||
const target = ev.target.closest('a'); | ||
if ( target instanceof HTMLAnchorElement === false ) { return; } | ||
if ( updateStockLists(target) === true ) { | ||
ev.stopPropagation(); | ||
ev.preventDefault(); | ||
} | ||
}); | ||
|
||
/******************************************************************************/ | ||
|
||
// <<<<< end of local scope | ||
})(); | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/******************************************************************************* | ||
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; |