1

I have tried removing content (paid content) from this website with uBlock origin, Greasemonkey and Anti-Adblock Killer script.

I have tried running this script but without success.
The ("paid") content I want to remove looks like this:

<div class="news" info="398825">
    <div class="normal" ...>
        <div class="supertitle">
            <a href="http://www.monitor.hr/marketing/sponzorirana.html" target="_blank">Sponzorirana vijest</a>
        </div>
        ...

I can differentiate "paid content" from rest of the content with this element:

<a href="http://www.monitor.hr/marketing/sponzorirana.html" target="_blank">Sponzorirana vijest</a>

I would like to remove every "paid content" ("Sponzorirana vijest") section from the linked website.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Cikson
  • 106
  • 2
  • 17

3 Answers3

1

That content appears to be static. So just leverage the page's jQuery like so:

// ==UserScript==
// @name     _Remove sponsored content
// @match    *://www.monitor.hr/*
// @grant    none
// ==/UserScript==

$(".supertitle > a[href*='marketing/sponzorirana']").closest (".news").remove ();


If more of those blocks are added dynamically, use waitForKeyElements() as shown in this answer. Something like this (untested in GM4):

// ==UserScript==
// @name     _Remove sponsored content
// @match    *://www.monitor.hr/*
// @require  https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant    none
// ==/UserScript==
waitForKeyElements (".supertitle > a[href*='marketing/sponzorirana']", removeNewsNode);

function removeNewsNode (jNode) {
    jNode.closest (".news").remove ();
}



Finally, per Greasemonkey's own developers, switch to Tampermonkey or Violentmonkey. Greasemonkey 4+ has serious deficiencies.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
0

And here is the script that works, just paste it into tampermonkey or greasemonkey.

// ==UserScript==
// @name         Disable for sponsored news
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        http://www.monitor.hr/
// @grant        none
// ==/UserScript==

(function() {
    $("a:contains('Sponzorirana vijest')").closest('.news').css('display', 'none');
})();

Script explained. @match shows on which website to apply it. Function parts is jquery that selects node of class news that is closest to the anchor tag that contains string Sponzorirana vijest, when selected display: none is applied.

Milan
  • 203
  • 2
  • 11
  • Close, but the `@match` is off and `.hide()` is better than that `.css` call. – Brock Adams Jan 26 '18 at 20:07
  • @Brock Adams, I agree that `.hide()` makes code shorter and therefore cleaner, but have in mind that it does the same thing like the css from the example. And for `@match`, could you explain how it is off since the script works as it is. – Milan Jan 26 '18 at 20:25
  • Don't ask a new question in a comment edit. We don't normally see those (comment alert only goes out once). I called the match "off", both because it will break when the site goes to https, and also it **only works on the home page**. Both are easy fixes. See the `@match` in my answer and note the asterisks. – Brock Adams Jan 26 '18 at 20:33
0

I've created this custom filter in uBlock and it works like a charm:

www.monitor.hr##.tag-sponzorirana-vijest.category-vijest
john
  • 1