1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 01:27:12 +02:00

this fixes #14

This commit is contained in:
gorhill 2014-06-25 18:44:35 -04:00
parent b31d868a42
commit 1c3fc6f557
4 changed files with 27 additions and 5 deletions

View File

@ -135,6 +135,20 @@ var CosmeticFiltering = function() {
};
CosmeticFiltering.prototype.onDOMContentLoaded = function() {
// https://github.com/gorhill/uBlock/issues/14
// Treat any existing domain-specific exception selectors as if they had
// been injected already.
var style = document.getElementById('uBlock1ae7a5f130fc79b4fdb8a4272d9426b5');
var exceptions = style && style.getAttribute('uBlock1ae7a5f130fc79b4fdb8a4272d9426b5');
if ( exceptions ) {
exceptions = decodeURIComponent(exceptions).split('\n');
var i = exceptions.length;
while ( i-- ) {
this.injectedSelectors[exceptions[i]] = true;
}
}
// TODO: evaluate merging into a single loop
this.classesFromNodeList(document.querySelectorAll('*[class]'));
this.idsFromNodeList(document.querySelectorAll('*[id]'));
this.retrieveGenericSelectors();
@ -218,11 +232,10 @@ CosmeticFiltering.prototype.filterUnfiltered = function(inSelectors, outSelector
};
CosmeticFiltering.prototype.reduce = function(selectors, dict) {
var first = dict.µb === undefined;
var i = selectors.length, selector, end;
while ( i-- ) {
selector = selectors[i];
if ( first || !dict[selector] ) {
if ( !dict[selector] ) {
if ( end !== undefined ) {
selectors.splice(i+1, end-i);
end = undefined;
@ -235,7 +248,6 @@ CosmeticFiltering.prototype.reduce = function(selectors, dict) {
if ( end !== undefined ) {
selectors.splice(0, end+1);
}
dict.µb = true;
};
CosmeticFiltering.prototype.classesFromNodeList = function(nodes) {

View File

@ -155,6 +155,16 @@ var domainCosmeticFilteringHandler = function(selectors) {
if ( styleText.length > 0 ) {
var style = document.createElement('style');
style.appendChild(document.createTextNode(styleText.join('\n')));
if ( selectors.donthide.length > 0 ) {
style.setAttribute(
'id',
'uBlock1ae7a5f130fc79b4fdb8a4272d9426b5'
);
style.setAttribute(
'uBlock1ae7a5f130fc79b4fdb8a4272d9426b5',
encodeURIComponent(selectors.donthide.join('\n'))
);
}
var parent = document.head || document.documentElement;
if ( parent ) {
parent.appendChild(style);

View File

@ -101,7 +101,7 @@ var onBeforeRequestHandler = function(details) {
}
// Blocked
// console.debug('onBeforeRequestHandler()> BLOCK "%s": %o', details.url, details);
//console.debug('µBlock> onBeforeRequestHandler()> BLOCK "%s" because "%s"', details.url, reason);
// Redirect to noop versions whenever possible.
var redirectPath = typeToRedirectPathMap[requestType];

View File

@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "__MSG_extName__",
"short_name": "µBlock",
"version": "0.1.0.7",
"version": "0.1.0.8",
"description": "__MSG_extShortDesc__",
"icons": {
"16": "img/icon_16.png",