Skip to content

Commit

Permalink
Add remove-class scriptlet (alias: rc)
Browse files Browse the repository at this point in the history
Related issue:
- uBlockOrigin/uBlock-issues#935

Arguments are similar to that of remove-attr
scriptlet.
  • Loading branch information
gorhill authored and JustOff committed Jun 14, 2020
1 parent d7cf0bc commit 58978f4
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions assets/resources/resources.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,34 @@ remove-attr.js application/javascript
})();


remove-class.js application/javascript
(function() {
var token = '{{1}}';
if ( token === '' || token === '{{1}}' ) { return; }
var tokens = token.split(/\s*\|\s*/);
var selector = '{{2}}';
if ( selector === '' || selector === '{{2}}' ) {
selector = '.' + tokens.map(a => CSS.escape(a)).join(',.');
}
var rmclass = function(ev) {
if ( ev ) { window.removeEventListener(ev.type, rmclass, true); }
try {
var nodes = document.querySelectorAll(selector), i = nodes.length;
while ( i-- ) {
var node = nodes[i];
node.classList.remove(...tokens);
}
} catch(ex) {
}
};
if ( document.readyState === 'loading' ) {
window.addEventListener('DOMContentLoaded', rmclass, true);
} else {
rmclass();
}
})();


# https://github.com/gorhill/uBlock/commit/6831967f5f9d64412a9c063f3b64104d9dce7b07
requestAnimationFrame-if.js application/javascript
(function() {
Expand Down

0 comments on commit 58978f4

Please sign in to comment.