How do I block ads on startpage.com?

I tried the following, it has no effect:

startpage.com##[style*="background-color:#F5F9FF;"]

Any idea how to solve this?

To reproduce: Go to https://startpage.com/do/search - search for example for adblock. You'll see nasty light blue boxes at the top and bottom of the page reading "Ads related to adblock":

enter image description here

This is with Iceweasel (Firefox 38.2.1) and Adblock Edge 2.1.9.1.


If it's not possible, which secure/privacy-respecting and ad-free sites do you recommend as alternative to IxQuick and Startpage?


Any idea how to solve this?

The ads in question are in a div with ID "spon_links".

<div id="spon_links">

You can use a Greasemonkey script to remove these divs.


Solution 1

This is confirmed as working in Firefox when using the uBlock Origin ad blocker.

// ==UserScript==
// @name        startpage.com remove ads
// @namespace   startpage.com
// @description Removes ads from startpage.com before they are displayed.
// @include     https://startpage.com/*
// @include     https://*.startpage.com/*
// @run-at      document-start
// @version     2015-09-29
// @grant       GM_addStyle
// ==/UserScript==

GM_addStyle("div#spon_links { display: none !important}");

Solution 2

Not tested.

Replace 'ads' with 'spon_links' in the example script below.

4.9. Removing an element

You can use Greasemonkey to remove entire chunks of a page in one fell swoop, with the removeChild function.

Example: Remove an ad sidebar

This presumes that there is an element whose ID is "ads".

var adSidebar = document.getElementById('ads');
if (adSidebar) {
    adSidebar.parentNode.removeChild(adSidebar);
}

Removing an element with removeChild will also remove all the content inside it. For example, if you remove a <table> element, this will also remove all of its table cells (<td> elements).

Source 4.9. Removing an element


Following @DavidPostill's notice, I looked again at the page structure. It appears that the text ads are moved outside the div.spon_links when Adblock Edge is enabled which indeed has a filtering rule for spon_links. Whether this is a misbehaviour of Adblock Edge or some counter-action from Startpage I don't know.

There is a simpler solution than adding a custom Greasemonkey script—simply swapping Adblock Edge for uBlock also solved the problem.


On further investigation, the ads only disappear with uBlock enabled when Adblock Edge is entirely disabled at the same time ("Disable everywhere"). Even if I disable it only for Startpage ("Disable on startpage.com"), the site moves the ads outside the spon_links container. My explanation is that Startpage somehow manages to access my Add-ons preferences and checks if Adblock is generally enabled. Could it be that nasty?!


Using David's approach of Greasemonkey and removeChild, I came up with the following solution that still works when Adblock Edge is installed. It seems one has to wait till the page has loaded and toyed around with avoiding ad-block, until you can finally locate and delete the offending elements:

// ==UserScript==
// @name        startpage/ixquick remove ads
// @namespace   startpage.com
// @description Removes ads from startpage/ixquick before they are displayed.
// @include     https://startpage.com/*
// @include     https://*.startpage.com/*
// @include     https://ixquick.com/*
// @include     https://*.ixquick.com/*
// @run-at      document-end
// @grant       none
// @version     2015-09-29
// ==/UserScript==

var fun = function() {
  var results = document.getElementById('bottom-result-container');
  if (results) {
    var ols = results.getElementsByTagName('ol');
    for (i = 0; i < ols.length; i++) {
      var ol = ols[i];
      var ps = ol.getElementsByTagName('p');
      for (j = 0; j < ps.length; j++) {
        var p = ps[j];
        if (p.className == 'head2') {
          var spans = p.getElementsByTagName('span');
          for (k = 0; k < spans.length; k++) {
            if (spans[k].innerHTML.contains("Ads related to")) {
              ol.innerHTML = '';
            }
          }
        }
      }
    }
  }
};
setTimeout(fun, 1);

(Sorry, my JavaScript is a bit rusty, probably easier with jQuery.)