Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
mneunomne committed Nov 6, 2021
2 parents 6aa4d49 + d5ced9b commit ea19794
Show file tree
Hide file tree
Showing 109 changed files with 1,406 additions and 537 deletions.
17 changes: 17 additions & 0 deletions assets/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,23 @@
"supportURL": "https://github.com/AdguardTeam/AdguardFilters#adguard-filters",
"instructionURL": "https://kb.adguard.com/en/general/adguard-ad-filters"
},
"adguard-spyware-url": {
"content": "filters",
"group": "privacy",
"off": true,
"title": "AdGuard URL Tracking Protection",
"contentURL": "https://filters.adtidy.org/extension/ublock/filters/17.txt",
"supportURL": "https://github.com/AdguardTeam/AdguardFilters#adguard-filters",
"instructionURL": "https://kb.adguard.com/en/general/adguard-ad-filters"
},
"block-lan": {
"content": "filters",
"group": "privacy",
"off": true,
"title": "Block access to LAN",
"contentURL": "https://raw.githubusercontent.com/gwarser/filter-lists/master/lan-block.txt",
"supportURL": "https://github.com/gwarser/filter-lists"
},
"easyprivacy": {
"content": "filters",
"group": "privacy",
Expand Down
74 changes: 52 additions & 22 deletions assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,31 @@



/// abort-current-inline-script.js
/// abort-current-script.js
/// alias acs.js
/// alias abort-current-inline-script.js
/// alias acis.js
(function() {
const target = '{{1}}';
if ( target === '' || target === '{{1}}' ) { return; }
const reRegexEscape = /[.*+?^${}()|[\]\\]/g;
const needle = '{{2}}';
let reText = '.?';
if ( needle !== '' && needle !== '{{2}}' ) {
reText = /^\/.+\/$/.test(needle)
? needle.slice(1,-1)
: needle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
const reNeedle = (( ) => {
if ( needle === '' || needle === '{{2}}' ) { return /^/; }
if ( /^\/.+\/$/.test(needle) ) {
return new RegExp(needle.slice(1,-1));
}
return new RegExp(needle.replace(reRegexEscape, '\\$&'));
})();
const context = '{{3}}';
const reContext = (( ) => {
if ( context === '' || context === '{{3}}' ) { return /^$/; }
if ( /^\/.+\/$/.test(context) ) {
return new RegExp(context.slice(1,-1));
}
return new RegExp(context.replace(reRegexEscape, '\\$&'));
})();
const thisScript = document.currentScript;
const re = new RegExp(reText);
const chain = target.split('.');
let owner = window;
let prop;
Expand All @@ -66,16 +77,35 @@
}
const magic = String.fromCharCode(Date.now() % 26 + 97) +
Math.floor(Math.random() * 982451653 + 982451653).toString(36);
const validate = function() {
const e = document.currentScript;
if (
e instanceof HTMLScriptElement &&
e.src === '' &&
e !== thisScript &&
re.test(e.textContent)
) {
throw new ReferenceError(magic);
const scriptTexts = new WeakMap();
const getScriptText = elem => {
let text = elem.textContent;
if ( text.trim() !== '' ) { return text; }
if ( scriptTexts.has(elem) ) { return scriptTexts.get(elem); }
const [ , mime, content ] =
/^data:([^,]*),(.+)$/.exec(elem.src.trim()) ||
[ '', '', '' ];
try {
switch ( true ) {
case mime.endsWith(';base64'):
text = self.atob(content);
break;
default:
text = self.decodeURIComponent(content);
break;
}
} catch(ex) {
}
scriptTexts.set(elem, text);
return text;
};
const validate = ( ) => {
const e = document.currentScript;
if ( e instanceof HTMLScriptElement === false ) { return; }
if ( reContext.test(e.src) === false ) { return; }
if ( e === thisScript ) { return; }
if ( reNeedle.test(getScriptText(e)) === false ) { return; }
throw new ReferenceError(magic);
};
Object.defineProperty(owner, prop, {
get: function() {
Expand All @@ -95,7 +125,7 @@
});
const oe = window.onerror;
window.onerror = function(msg) {
if ( typeof msg === 'string' && msg.indexOf(magic) !== -1 ) {
if ( typeof msg === 'string' && msg.includes(magic) ) {
return true;
}
if ( oe instanceof Function ) {
Expand Down Expand Up @@ -731,7 +761,7 @@
}
}
if ( skip ) { return; }
timer = self.requestIdleCallback(rmattr, { timeout: 67 });
timer = self.requestIdleCallback(rmattr, { timeout: 17 });
};
const start = ( ) => {
rmattr();
Expand All @@ -746,10 +776,10 @@
};
if ( document.readyState !== 'complete' && /\bcomplete\b/.test(behavior) ) {
self.addEventListener('load', start, { once: true });
} else if ( document.readyState === 'loading' ) {
self.addEventListener('DOMContentLoaded', start, { once: true });
} else {
} else if ( document.readyState !== 'loading' || /\basap\b/.test(behavior) ) {
start();
} else {
self.addEventListener('DOMContentLoaded', start, { once: true });
}
})();

Expand Down
4 changes: 2 additions & 2 deletions dist/firefox/updates.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"[email protected]": {
"updates": [
{
"version": "1.35.3.105",
"version": "1.36.3.101",
"browser_specific_settings": { "gecko": { "strict_min_version": "57" } },
"update_link": "https://github.com/gorhill/uBlock/releases/download/1.35.3rc5/uBlock0_1.35.3rc5.firefox.signed.xpi"
"update_link": "https://github.com/gorhill/uBlock/releases/download/1.36.3rc1/uBlock0_1.36.3rc1.firefox.signed.xpi"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion dist/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.36.0
1.37.0
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,64 @@

/******************************************************************************/

(( ) => {
// https://github.com/uBlockOrigin/uBlock-issues/issues/407
if ( vAPI.webextFlavor.soup.has('chromium') === false ) { return; }
// https://github.com/uBlockOrigin/uBlock-issues/issues/1659
// Chromium fails to dispatch onCreatedNavigationTarget() events sometimes,
// so we synthetize these missing events when this happens.

vAPI.Tabs = class extends vAPI.Tabs {
constructor() {
super();
this.tabIds = new Set();
browser.tabs.onCreated.addListener(tab => {
this.onCreatedHandler(tab);
});
}

onCreatedHandler(tab) {
if ( typeof tab.openerTabId === 'number' ) { return; }
if ( tab.index !== 0 ) { return; }
if ( tab.url !== '' ) { return; }
this.tabIds.add(tab.id);
}

onCreatedNavigationTargetHandler(details) {
this.tabIds.delete(details.tabId);
super.onCreatedNavigationTargetHandler(details);
}

onCommittedHandler(details) {
if ( details.frameId === 0 ) {
this.synthesizeNavigationTargetEvent(details);
}
super.onCommittedHandler(details);
}

onRemovedHandler(tabId, details) {
this.tabIds.delete(tabId);
super.onRemovedHandler(tabId, details);
}

synthesizeNavigationTargetEvent(details) {
if ( this.tabIds.has(details.tabId) === false ) { return; }
this.tabIds.delete(details.tabId);
if (
Array.isArray(details.transitionQualifiers) === false ||
details.transitionQualifiers.includes('client_redirect') === false
) {
return;
}
this.onCreatedNavigationTargetHandler({
tabId: details.tabId,
sourceTabId: details.tabId,
sourceFrameId: 0,
url: details.url,
});
}
};

/******************************************************************************/

{
const extToTypeMap = new Map([
['eot','font'],['otf','font'],['svg','font'],['ttf','font'],['woff','font'],['woff2','font'],
['mp3','media'],['mp4','media'],['webm','media'],
Expand All @@ -54,6 +108,7 @@
super();
this.suspendedTabIds = new Set();
}

normalizeDetails(details) {
// Chromium 63+ supports the `initiator` property, which contains
// the URL of the origin from which the network request was made.
Expand Down Expand Up @@ -100,6 +155,7 @@
}
}
}

// https://www.reddit.com/r/uBlockOrigin/comments/9vcrk3/
// Some types can be mapped from 'other', thus include 'other' if and
// only if the caller is interested in at least one of those types.
Expand All @@ -123,18 +179,20 @@
}
return Array.from(out);
}

suspendOneRequest(details) {
this.suspendedTabIds.add(details.tabId);
return { cancel: true };
}

unsuspendAllRequests() {
for ( const tabId of this.suspendedTabIds ) {
vAPI.tabs.reload(tabId);
}
this.suspendedTabIds.clear();
}
};
})();
}

/******************************************************************************/

Expand All @@ -143,9 +201,6 @@
// setting "Predict network actions to improve page load performance".

vAPI.prefetching = (( ) => {
// https://github.com/uBlockOrigin/uBlock-issues/issues/407
if ( vAPI.webextFlavor.soup.has('chromium') === false ) { return; }

let listening = false;

const onHeadersReceived = function(details) {
Expand Down
1 change: 1 addition & 0 deletions platform/chromium/webext.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const webext = {
},
onClicked: chrome.contextMenus.onClicked,
remove: promisifyNoFail(chrome.contextMenus, 'remove'),
removeAll: promisifyNoFail(chrome.contextMenus, 'removeAll'),
},
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/privacy
privacy: {
Expand Down
File renamed without changes.
Loading

0 comments on commit ea19794

Please sign in to comment.