Skip to content
Permalink
Browse files
Add remove-class scriptlet (alias: rc)
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 58978f4051b93c1aac6435aae557037a51612ec8
Showing with 28 additions and 0 deletions.
  1. +28 −0 assets/resources/resources.txt
@@ -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() {

0 comments on commit 58978f4

Please sign in to comment.