mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
bringing changes from master
This commit is contained in:
commit
e8045d154b
@ -1,6 +1,6 @@
|
|||||||
6572a7bce5f1747fee597cb170bd3b98 assets/ublock/privacy.txt
|
6572a7bce5f1747fee597cb170bd3b98 assets/ublock/privacy.txt
|
||||||
8ebba513a75ed3f7ed964688c2c6071c assets/ublock/filters.txt
|
8ebba513a75ed3f7ed964688c2c6071c assets/ublock/filters.txt
|
||||||
4d9e52dd0f2fa7b4ff3c80043096e542 assets/ublock/mirror-candidates.txt
|
dcf3e05bae803343c9d632f0baf8bedd assets/ublock/mirror-candidates.txt
|
||||||
b3ec069f792cec05484e6c45b3591466 assets/ublock/filter-lists.json
|
b3ec069f792cec05484e6c45b3591466 assets/ublock/filter-lists.json
|
||||||
132b3ecc9da8a68c3faf740c00af734b assets/thirdparties/adblock-plus-japanese-filter.googlecode.com/hg/abp_jp.txt
|
132b3ecc9da8a68c3faf740c00af734b assets/thirdparties/adblock-plus-japanese-filter.googlecode.com/hg/abp_jp.txt
|
||||||
94c0a3eab74c42783855f07b22a429cf assets/thirdparties/home.fredfiber.no/langsholt/adblock.txt
|
94c0a3eab74c42783855f07b22a429cf assets/thirdparties/home.fredfiber.no/langsholt/adblock.txt
|
||||||
|
@ -19,7 +19,7 @@ code.jquery.com
|
|||||||
# within a data: URI
|
# within a data: URI
|
||||||
^code\.jquery\.com\/(?!.*\/themes\/.+\.css)
|
^code\.jquery\.com\/(?!.*\/themes\/.+\.css)
|
||||||
maxcdn.bootstrapcdn.com
|
maxcdn.bootstrapcdn.com
|
||||||
^maxcdn\.bootstrapcdn\.com\/font-awesome\/
|
^maxcdn\.bootstrapcdn\.com\/bootstrap\/.+\/.+\.js
|
||||||
netdna.bootstrapcdn.com
|
netdna.bootstrapcdn.com
|
||||||
^netdna\.bootstrapcdn\.com\/bootstrap\/
|
^netdna\.bootstrapcdn\.com\/bootstrap\/
|
||||||
^netdna\.bootstrapcdn\.com\/font-awesome\/
|
^netdna\.bootstrapcdn\.com\/font-awesome\/
|
||||||
|
@ -86,18 +86,22 @@ vAPI.tabs.get = function(tabId, callback) {
|
|||||||
var onTabReady = function(tab) {
|
var onTabReady = function(tab) {
|
||||||
// https://code.google.com/p/chromium/issues/detail?id=410868#c8
|
// https://code.google.com/p/chromium/issues/detail?id=410868#c8
|
||||||
if ( chrome.runtime.lastError ) {
|
if ( chrome.runtime.lastError ) {
|
||||||
return;
|
;
|
||||||
}
|
}
|
||||||
|
// Caller must be prepared to deal with nil tab value
|
||||||
callback(tab);
|
callback(tab);
|
||||||
};
|
};
|
||||||
if ( tabId !== null ) {
|
if ( tabId !== null ) {
|
||||||
|
if ( typeof tabId === 'string' ) {
|
||||||
|
tabId = parseInt(tabId, 10);
|
||||||
|
}
|
||||||
chrome.tabs.get(tabId, onTabReady);
|
chrome.tabs.get(tabId, onTabReady);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var onTabReceived = function(tabs) {
|
var onTabReceived = function(tabs) {
|
||||||
// https://code.google.com/p/chromium/issues/detail?id=410868#c8
|
// https://code.google.com/p/chromium/issues/detail?id=410868#c8
|
||||||
if ( chrome.runtime.lastError ) {
|
if ( chrome.runtime.lastError ) {
|
||||||
return;
|
;
|
||||||
}
|
}
|
||||||
callback(tabs[0]);
|
callback(tabs[0]);
|
||||||
};
|
};
|
||||||
|
@ -36,6 +36,13 @@ self.vAPI = self.vAPI || {};
|
|||||||
var chrome = self.chrome;
|
var chrome = self.chrome;
|
||||||
var vAPI = self.vAPI;
|
var vAPI = self.vAPI;
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/456
|
||||||
|
// Already injected?
|
||||||
|
if ( vAPI.vapiClientInjected ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vAPI.vapiClientInjected = true;
|
||||||
|
|
||||||
vAPI.chrome = true;
|
vAPI.chrome = true;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -21,18 +21,27 @@
|
|||||||
|
|
||||||
/* global vAPI */
|
/* global vAPI */
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// Injected into content pages
|
// Injected into content pages
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
if ( vAPI.canExecuteContentScript() !== true ) {
|
if ( vAPI.canExecuteContentScript() !== true ) {
|
||||||
throw "uBlock> contentscript-end.js > Skipping " + location.protocol;
|
throw "uBlock> contentscript-end.js > Skipping " + location.protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/456
|
||||||
|
// Already injected?
|
||||||
|
if ( vAPI.contentscriptEndInjected ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vAPI.contentscriptEndInjected = true;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var messager = vAPI.messaging.channel('contentscript-end.js');
|
var messager = vAPI.messaging.channel('contentscript-end.js');
|
||||||
@ -259,15 +268,20 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
|
|||||||
node = nodeList[iNode];
|
node = nodeList[iNode];
|
||||||
attrValue = node.getAttribute(attr);
|
attrValue = node.getAttribute(attr);
|
||||||
if ( !attrValue ) { continue; }
|
if ( !attrValue ) { continue; }
|
||||||
|
// Candidate 1 = generic form
|
||||||
|
// If generic form is injected, no need to process the specific
|
||||||
|
// form, as the generic will affect all related specific forms
|
||||||
selector = '[' + attr + '="' + attrValue + '"]';
|
selector = '[' + attr + '="' + attrValue + '"]';
|
||||||
if ( generics[selector] ) {
|
if ( generics.hasOwnProperty(selector) ) {
|
||||||
if ( injectedSelectors.hasOwnProperty(selector) === false ) {
|
if ( injectedSelectors.hasOwnProperty(selector) === false ) {
|
||||||
injectedSelectors[selector] = true;
|
injectedSelectors[selector] = true;
|
||||||
out.push(selector);
|
out.push(selector);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Candidate 2 = specific form
|
||||||
selector = node.tagName.toLowerCase() + selector;
|
selector = node.tagName.toLowerCase() + selector;
|
||||||
if ( generics[selector] ) {
|
if ( generics.hasOwnProperty(selector) ) {
|
||||||
if ( injectedSelectors.hasOwnProperty(selector) === false ) {
|
if ( injectedSelectors.hasOwnProperty(selector) === false ) {
|
||||||
injectedSelectors[selector] = true;
|
injectedSelectors[selector] = true;
|
||||||
out.push(selector);
|
out.push(selector);
|
||||||
@ -672,3 +686,8 @@ var messager = vAPI.messaging.channel('contentscript-end.js');
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
@ -44,6 +44,13 @@ if ( vAPI.canExecuteContentScript() !== true ) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/456
|
||||||
|
// Already injected?
|
||||||
|
if ( vAPI.contentscriptStartInjected ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vAPI.contentscriptStartInjected = true;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var localMessager = vAPI.messaging.channel('contentscript-start.js');
|
var localMessager = vAPI.messaging.channel('contentscript-start.js');
|
||||||
@ -55,14 +62,9 @@ var localMessager = vAPI.messaging.channel('contentscript-start.js');
|
|||||||
// These can be inserted before the DOM is loaded.
|
// These can be inserted before the DOM is loaded.
|
||||||
|
|
||||||
var cosmeticFilters = function(details) {
|
var cosmeticFilters = function(details) {
|
||||||
// Maybe uBlock's style tag was already injected?
|
|
||||||
var style = document.getElementById('ublock-preload-1ae7a5f130fc79b4fdb8a4272d9426b5');
|
|
||||||
if ( style !== null ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var donthideCosmeticFilters = {};
|
var donthideCosmeticFilters = {};
|
||||||
var hideCosmeticFilters = {};
|
var hideCosmeticFilters = {};
|
||||||
style = document.createElement('style');
|
var style = document.createElement('style');
|
||||||
style.setAttribute('id', 'ublock-preload-1ae7a5f130fc79b4fdb8a4272d9426b5');
|
style.setAttribute('id', 'ublock-preload-1ae7a5f130fc79b4fdb8a4272d9426b5');
|
||||||
var donthide = details.cosmeticDonthide;
|
var donthide = details.cosmeticDonthide;
|
||||||
var hide = details.cosmeticHide;
|
var hide = details.cosmeticHide;
|
||||||
|
@ -778,7 +778,9 @@ FilterContainer.prototype.freezeHighGenerics = function(what) {
|
|||||||
}
|
}
|
||||||
var highHighGenericCount = 0;
|
var highHighGenericCount = 0;
|
||||||
|
|
||||||
var reHighLow = /^[a-z]*(\[(?:alt|title)="[^"]+"\])$/;
|
// https://github.com/gorhill/uBlock/issues/456
|
||||||
|
// Include tag name, it's part of the filter
|
||||||
|
var reHighLow = /^[a-z]*\[(?:alt|title)="[^"]+"\]$/;
|
||||||
var reHighMedium = /^\[href\^="https?:\/\/([^"]{8})[^"]*"\]$/;
|
var reHighMedium = /^\[href\^="https?:\/\/([^"]{8})[^"]*"\]$/;
|
||||||
var matches, hash;
|
var matches, hash;
|
||||||
|
|
||||||
@ -788,8 +790,8 @@ FilterContainer.prototype.freezeHighGenerics = function(what) {
|
|||||||
}
|
}
|
||||||
// ["title"] and ["alt"] will go in high-low generic bin.
|
// ["title"] and ["alt"] will go in high-low generic bin.
|
||||||
matches = reHighLow.exec(selector);
|
matches = reHighLow.exec(selector);
|
||||||
if ( matches && matches.length === 2 ) {
|
if ( matches && matches.length === 1 ) {
|
||||||
highLowGeneric[matches[1]] = true;
|
highLowGeneric[matches[0]] = true;
|
||||||
highLowGenericCount += 1;
|
highLowGenericCount += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -19,18 +19,29 @@
|
|||||||
Home: https://github.com/gorhill/uBlock
|
Home: https://github.com/gorhill/uBlock
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* global µBlock */
|
/* global vAPI, µBlock */
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
var µb = µBlock;
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
// When the DOM content of root frame is loaded, this means the tab
|
// When the DOM content of root frame is loaded, this means the tab
|
||||||
// content has changed.
|
// content has changed.
|
||||||
vAPI.tabs.onNavigation = function(details) {
|
vAPI.tabs.onNavigation = function(details) {
|
||||||
if ( details.frameId !== 0 ) {
|
if ( details.frameId !== 0 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
µBlock.bindTabToPageStats(details.tabId, details.url);
|
µb.bindTabToPageStats(details.tabId, details.url);
|
||||||
};
|
};
|
||||||
|
|
||||||
// It may happen the URL in the tab changes, while the page's document
|
// It may happen the URL in the tab changes, while the page's document
|
||||||
@ -43,21 +54,21 @@ vAPI.tabs.onUpdated = function(tabId, changeInfo, tab) {
|
|||||||
if ( !changeInfo.url ) {
|
if ( !changeInfo.url ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
µBlock.bindTabToPageStats(tabId, changeInfo.url, 'tabUpdated');
|
µb.bindTabToPageStats(tabId, changeInfo.url, 'tabUpdated');
|
||||||
};
|
};
|
||||||
|
|
||||||
vAPI.tabs.onClosed = function(tabId) {
|
vAPI.tabs.onClosed = function(tabId) {
|
||||||
if ( tabId < 0 ) {
|
if ( tabId < 0 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
µBlock.unbindTabFromPageStats(tabId);
|
µb.unbindTabFromPageStats(tabId);
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://github.com/gorhill/uBlock/issues/297
|
// https://github.com/gorhill/uBlock/issues/297
|
||||||
vAPI.tabs.onPopup = function(details) {
|
vAPI.tabs.onPopup = function(details) {
|
||||||
//console.debug('vAPI.tabs.onPopup: url="%s"', details.url);
|
//console.debug('vAPI.tabs.onPopup: url="%s"', details.url);
|
||||||
|
|
||||||
var pageStore = µBlock.pageStoreFromTabId(details.sourceTabId);
|
var pageStore = µb.pageStoreFromTabId(details.sourceTabId);
|
||||||
if ( !pageStore ) {
|
if ( !pageStore ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -66,8 +77,8 @@ vAPI.tabs.onPopup = function(details) {
|
|||||||
|
|
||||||
// https://github.com/gorhill/uBlock/issues/323
|
// https://github.com/gorhill/uBlock/issues/323
|
||||||
// If popup URL is whitelisted, do not block it
|
// If popup URL is whitelisted, do not block it
|
||||||
if ( µBlock.getNetFilteringSwitch(requestURL) ) {
|
if ( µb.getNetFilteringSwitch(requestURL) ) {
|
||||||
result = µBlock.staticNetFilteringEngine.matchStringExactType(pageStore, requestURL, 'popup');
|
result = µb.staticNetFilteringEngine.matchStringExactType(pageStore, requestURL, 'popup');
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/gorhill/uBlock/issues/91
|
// https://github.com/gorhill/uBlock/issues/91
|
||||||
@ -83,7 +94,7 @@ vAPI.tabs.onPopup = function(details) {
|
|||||||
// Blocked
|
// Blocked
|
||||||
|
|
||||||
// It is a popup, block and remove the tab.
|
// It is a popup, block and remove the tab.
|
||||||
µBlock.unbindTabFromPageStats(details.tabId);
|
µb.unbindTabFromPageStats(details.tabId);
|
||||||
vAPI.tabs.remove(details.tabId);
|
vAPI.tabs.remove(details.tabId);
|
||||||
|
|
||||||
// for Safari
|
// for Safari
|
||||||
@ -92,7 +103,6 @@ vAPI.tabs.onPopup = function(details) {
|
|||||||
|
|
||||||
vAPI.tabs.registerListeners();
|
vAPI.tabs.registerListeners();
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
@ -106,7 +116,7 @@ vAPI.tabs.registerListeners();
|
|||||||
// hostname. This way, for a specific scheme you can create scope with
|
// hostname. This way, for a specific scheme you can create scope with
|
||||||
// rules which will apply only to that scheme.
|
// rules which will apply only to that scheme.
|
||||||
|
|
||||||
µBlock.normalizePageURL = function(pageURL) {
|
µb.normalizePageURL = function(pageURL) {
|
||||||
var uri = this.URI.set(pageURL);
|
var uri = this.URI.set(pageURL);
|
||||||
if ( uri.scheme === 'https' || uri.scheme === 'http' ) {
|
if ( uri.scheme === 'https' || uri.scheme === 'http' ) {
|
||||||
return uri.normalizedURI();
|
return uri.normalizedURI();
|
||||||
@ -118,7 +128,7 @@ vAPI.tabs.registerListeners();
|
|||||||
|
|
||||||
// Create an entry for the tab if it doesn't exist.
|
// Create an entry for the tab if it doesn't exist.
|
||||||
|
|
||||||
µBlock.bindTabToPageStats = function(tabId, pageURL, context) {
|
µb.bindTabToPageStats = function(tabId, pageURL, context) {
|
||||||
this.updateBadgeAsync(tabId);
|
this.updateBadgeAsync(tabId);
|
||||||
|
|
||||||
// https://github.com/gorhill/httpswitchboard/issues/303
|
// https://github.com/gorhill/httpswitchboard/issues/303
|
||||||
@ -146,7 +156,7 @@ vAPI.tabs.registerListeners();
|
|||||||
return pageStore;
|
return pageStore;
|
||||||
};
|
};
|
||||||
|
|
||||||
µBlock.unbindTabFromPageStats = function(tabId) {
|
µb.unbindTabFromPageStats = function(tabId) {
|
||||||
//console.debug('µBlock> unbindTabFromPageStats(%d)', tabId);
|
//console.debug('µBlock> unbindTabFromPageStats(%d)', tabId);
|
||||||
var pageStore = this.pageStores[tabId];
|
var pageStore = this.pageStores[tabId];
|
||||||
if ( pageStore !== undefined ) {
|
if ( pageStore !== undefined ) {
|
||||||
@ -157,27 +167,60 @@ vAPI.tabs.registerListeners();
|
|||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
µBlock.pageUrlFromTabId = function(tabId) {
|
µb.pageUrlFromTabId = function(tabId) {
|
||||||
var pageStore = this.pageStores[tabId];
|
var pageStore = this.pageStores[tabId];
|
||||||
return pageStore ? pageStore.pageURL : '';
|
return pageStore ? pageStore.pageURL : '';
|
||||||
};
|
};
|
||||||
|
|
||||||
µBlock.pageUrlFromPageStats = function(pageStats) {
|
µb.pageUrlFromPageStats = function(pageStats) {
|
||||||
if ( pageStats ) {
|
if ( pageStats ) {
|
||||||
return pageStats.pageURL;
|
return pageStats.pageURL;
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
|
|
||||||
µBlock.pageStoreFromTabId = function(tabId) {
|
µb.pageStoreFromTabId = function(tabId) {
|
||||||
return this.pageStores[tabId];
|
return this.pageStores[tabId];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// µBlock.forceReload = function(pageURL) {
|
// Stale page store entries janitor
|
||||||
// var tabId = this.tabIdFromPageUrl(pageURL);
|
// https://github.com/gorhill/uBlock/issues/455
|
||||||
// if ( tabId ) {
|
|
||||||
// chrome.tabs.reload(tabId, { bypassCache: true });
|
var pageStoreJanitorPeriod = 15 * 60 * 1000;
|
||||||
// }
|
var pageStoreJanitorSampleAt = 0;
|
||||||
// };
|
var pageStoreJanitorSampleSize = 10;
|
||||||
|
|
||||||
|
var pageStoreJanitor = function() {
|
||||||
|
var vapiTabs = vAPI.tabs;
|
||||||
|
var tabIds = Object.keys(µb.pageStores).sort();
|
||||||
|
var checkTab = function(tabId) {
|
||||||
|
vapiTabs.get(tabId, function(tab) {
|
||||||
|
if ( !tab ) {
|
||||||
|
//console.error('tab.js> pageStoreJanitor(): stale page store found:', µb.pageUrlFromTabId(tabId));
|
||||||
|
µb.unbindTabFromPageStats(tabId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
if ( pageStoreJanitorSampleAt >= tabIds.length ) {
|
||||||
|
pageStoreJanitorSampleAt = 0;
|
||||||
|
}
|
||||||
|
var n = Math.min(pageStoreJanitorSampleAt + pageStoreJanitorSampleSize, tabIds.length);
|
||||||
|
for ( var i = pageStoreJanitorSampleAt; i < n; i++ ) {
|
||||||
|
checkTab(tabIds[i]);
|
||||||
|
}
|
||||||
|
pageStoreJanitorSampleAt = n;
|
||||||
|
|
||||||
|
setTimeout(pageStoreJanitor, pageStoreJanitorPeriod);
|
||||||
|
};
|
||||||
|
|
||||||
|
setTimeout(pageStoreJanitor, pageStoreJanitorPeriod);
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user