manual anti ads extension for google chrome (or Firefox)

06
2014-04
  • camcam

    I know about AdBlock extension. But in general, I don't want to block all ads. I'd like an extension, which allows me to Ctrl-click (or use another shortcut-click) on an ad which is disturbing and intelligently remove it from the page that I am browsing.

    I know it could be done also, by right clicking on a page, opening the Inspection panel, click on the Loop tool, click the add, go up the DOM and highlight <object> and press Delete. But it's too long.

    I remember once reading about a fancy jquery something, which blows elements on page in a spectacular way (unfortunately no idea what was the name). Perhaps something like this would do. Anything, the simpler, the better, But not automatic, just allow me to click&go. (in fact, it could allow to get rid of anything on the page, not only ad)

  • Answers
  • Dennis

    You can actually achieve this with AdBlock:

    • To avoid it from blocking anything by default, uncheck all items in the Filter lists.

    • To block a specific ad, right-click it and choose AdBlock -> Block this ad.

    This would have the advantage of remembering your actions.

    If you don't want to use AdBlock, you could try out this simple user script:

    // ==UserScript==
    // @name          NukeIt
    // @description   Nukes HTML elements with a single click.
    // ==/UserScript==
    
    var nukeItSetup = function() {
        function nukeIt(what) {
            if(!event.ctrlKey)
                return;
            event.preventDefault();
            var now = Number(new Date());
            if(now < nukeItTimer)
                return;
            nukeItTimer = now + 100;
            if(event.altKey) {
                if(nukeItElements.length)
                    nukeItElements.pop().style.display = nukeItProperties.pop();
            }
            else {
                nukeItElements.push(what);
                nukeItProperties.push(what.style.display);
                what.style.display = 'none';
            }   
        }
        var all = document.getElementsByTagName('*');
        for(var i = 0, j = all.length; i < j; i++)
            all[i].addEventListener('contextmenu', function(){nukeIt(this)});
    }
    
    var script = document.createElement('script');
    script.innerHTML = 'var nukeItTimer = 0, nukeItElements = [], nukeItProperties = []; (' + nukeItSetup.toString() + ')();';
    document.body.appendChild(script);
    

    How to use:

    • To install, (temporarily) save the code as nuke-it.user.js, drag and drop the file in Chrome and click Continue when asked if you want to.

    • To hide a HTML element, right-click it while pressing Ctrl.

    • To unhide the elements you hid (in reverse order), right-click anywhere while pressing Ctrl + Alt.


  • Related Question

    Google Chrome extensions in Firefox
  • Adrian Petrescu

    Chrome has a significantly more restricted extension API than Firefox; it mainly just consists of content scripts (with background pages) and a couple of hooks for context menus and popups and such. As such, it seems to me that a very significant subset of the Chrome API could be implemented in Firefox, either as a Firefox extension or a separate "extension compiler" like there exists for Greasemonkey scripts (which, incidentally, are another example of something that works exactly the same way as Chrome content scripts). If implemented, this would allow most Chrome extensions to install and run in Firefox.

    I Googled around a bit and found several mentions of a very old attempt at this, but all of the links to the actual Mozilla repository for it are now dead. Even if they weren't, I'd be very surprised if this early effort still worked with either Firefox 4 or the latest changes to the Chrome extension API.

    So my question is, does anybody know what the current state of the art is with regards to Chrome Extension API compatibility layers in Firefox? Have there been any extensions or extension compilers attempting to address the issues I brought up?


  • Related Answers
  • Patches

    If there is such a beast, even Mozilla developers don't know about it!

    Many Chrome "extensions" are just Greasemonkey scripts, and these can be used with the Greasemonkey extension or compiler on Firefox with no changes.

    Unfortunately, extensions that use other APIs must be ported. If you're looking to port a Chrome extension to Firefox, or planning to write one for both, take a look at Mozilla's new Jetpack extension API, which was designed to work in a manner similar to the way Chrome's extensions work, but still offer the vastly increased access to the browser the original Firefox API is known for.

  • niutech

    You can use You can use Extension Factory conversion tool in order to convert a Google Chrome extension to Firefox or Safari.