StartPage - Move ads to the sidebar bottom

It moves ads to the sidebar, avoiding unwanted clicks on them, including the AdBlock banner. Also removes those annoying Startpage promo banner.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        StartPage - Move ads to the sidebar bottom
// @namespace   https://startpage.com/
// @match       *://*startpage.com/*
// @icon        https://www.startpage.com/sp/cdn/favicons/favicon-32x32-gradient.png
// @version     202408100
// @author      Lukas ThyWalls
// @license     CC0
// @description It moves ads to the sidebar, avoiding unwanted clicks on them, including the AdBlock banner. Also removes those annoying Startpage promo banner.
// @run-at      document-end
// ==/UserScript==

// Run Check Function at every DOM change.
(new MutationObserver(check)).observe(document, {childList: true, subtree: true});

function check(changes, observer) {
    // If all Sidebar Block AND both Ads Block (top and bottom) are found/loaded...
    if(document.querySelector('#sidebar') &&
       (document.querySelector('#gcsa-top > iframe') && document.querySelector('#gcsa-bottom > iframe')) ||
       document.querySelector('.css-mtj8kd'))
    {
        // ... then stop checking ...
        observer.disconnect();
        // ... and move both Ads Blocks to the bottom of the sidebar.
        document.querySelector("#sidebar").appendChild(document.querySelector("#gcsa-top"));
        document.querySelector("#sidebar").appendChild(document.querySelector("#gcsa-bottom"));
        document.querySelector("#sidebar").appendChild(document.querySelector('div > .css-mtj8kd'));
    }
    // Check Sidebar Block and StartPage promo banner
    if(document.querySelector('#sidebar') &&
        document.querySelector(".serp-sidebar-app-promo-widget"))
    {
        // ... delete StartPage promo banner
        document.querySelector(".serp-sidebar-app-promo-widget").remove();
    }
    // Check bottom StartPage mobile promo banner
    if(document.querySelector('.serp-toast-container'))
    {
        // ... delete StartPage mobile promo banner
        document.querySelector('.serp-toast-container').remove();
    }
}