Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scriptlets remove-class and alert-buster-silent #935

Closed
5 of 8 tasks
Crystal-RainSlide opened this issue Mar 8, 2020 · 7 comments
Closed
5 of 8 tasks

Add scriptlets remove-class and alert-buster-silent #935

Crystal-RainSlide opened this issue Mar 8, 2020 · 7 comments
Labels
enhancement New feature or request fixed issue has been addressed

Comments

@Crystal-RainSlide
Copy link

Crystal-RainSlide commented Mar 8, 2020

Prerequisites

  • I verified that this is not a filter issue
  • This is not a support issue or a question
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue
    • Your issue may already be reported.
  • I tried to reproduce the issue when...
    • uBlock Origin is the only extension
    • uBlock Origin with default lists/settings
    • using a new, unmodified browser profile
  • I am running the latest version of uBlock Origin
  • I checked the documentation to understand that the issue I report is not a normal behavior

Description

On wikiHow, there is a class called hasad, and when the ad is blocked, this class causes some small issues on the appearance of the page.

'hasad' removes the padding

Writing UserStyle or :style rules helps, but remove those class works once for all. So, I hope there is a remove-class scriptlet to deal with what remove-attr can't do.

alert-buster-slient is less important. Maybe it's +js(alert-buster, slient), maybe there will be a scriptlet which can handle alart(), confirm() and prompt().

A specific URL where the issue occurs

https://www.wikihow.com/Prevent-Coronavirus

Steps to Reproduce

N/A

Expected behavior:

hasad can be removed by something succinct.

Actual behavior:

Have to use this:

// ==UserScript==
// @name              Remove class
// @namespace         RainSlide
// @icon              https://*.wikihow.com/*
// @version           1.0
// @grant             none
// @run-at            document-idle
// ==/UserScript==
document.querySelectorAll('.hasad').forEach(
  hasad => hasad.classList.remove("hasad")
);

Your environment

  • uBlock Origin version: v1.25.0
  • Browser Name and version: Firefox 73
  • Operating System and version: Windows 10
@uBlock-user uBlock-user changed the title [Suggestion] [scriptlets] remove-class and alert-buster-slient Add scriptlets remove-class and alert-buster-silent Mar 8, 2020
@uBlock-user uBlock-user added the enhancement New feature or request label Mar 8, 2020
@uBlock-user
Copy link
Contributor

this class causes some small issues on the appearance of the page.

What kind of issue ? I tested with my remove-class scriptlet, I see no change in appearance whatsoever.

@Crystal-RainSlide
Copy link
Author

@uBlock-user Tiny issue maybe. #intro has this style rule on it:

#intro.hasad {
	padding-bottom: 0px;
	border-bottom: 0;
}

Before:

Before

After:
After

Mainly I just can tell that, on other sites, this can be a real punch.

@uBlock-user
Copy link
Contributor

uBlock-user commented Mar 8, 2020

Some padding appears at the bottom border ?

Edit: I see the border getting cut out in presence of class .hasad but after removal, bottom border doesn't get cut.

@gwarser
Copy link

gwarser commented Mar 8, 2020

About dialogs: did you tried set-constant?

@Crystal-RainSlide
Copy link
Author

Some padding appears at the bottom border ?

Edit: I see the border getting cut out in presence of class .hasad but after removal, bottom border doesn't get cut.

Does it have any border? 🤔

CSS Rules

@Crystal-RainSlide
Copy link
Author

About dialogs: did you tried set-constant?

set-constant only works on JavaScript properties, it can't touch HTML, HTML attributes or CSS.

@Crystal-RainSlide
Copy link
Author

My own implementation to remove-class based on remove-attr.js and Element.classList, not very tested because I don't know how do {{1}} {{2}} works, but every part I modified should behave:

(function() {
    const token = '{{1}}';
    if ( token === '' || token === '{{1}}' ) { return; }
    const tokens = token.split(/\s*\|\s*/);
    let selector = '{{2}}';
    if ( selector === '' || selector === '{{2}}' ) {
        selector = `.${tokens.join(',.')}`;
    }
    const rmclass = function(ev) {
        if ( ev ) {
            window.removeEventListener(ev.type, rmclass, true);
        }
        try {
            const nodes = document.querySelectorAll(selector);
            for ( const node of nodes ) {
                node.classList.remove(...tokens);
            }
        } catch(ex) {
        }
    };
    if ( document.readyState === 'loading' ) {
        window.addEventListener('DOMContentLoaded', rmclass, true);
    } else {
        rmclass();
    }
})();

gorhill added a commit to gorhill/uBlock that referenced this issue Mar 18, 2020
Related issue:
- uBlockOrigin/uBlock-issues#935

Arguments are similar to that of remove-attr
scriptlet.
@gwarser gwarser added the fixed issue has been addressed label Mar 18, 2020
@gwarser gwarser closed this as completed Mar 18, 2020
JustOff pushed a commit to gorhill/uBlock-for-firefox-legacy that referenced this issue Jun 20, 2020
Related issue:
- uBlockOrigin/uBlock-issues#935

Arguments are similar to that of remove-attr
scriptlet.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed issue has been addressed
Projects
None yet
Development

No branches or pull requests

3 participants