Reddit Mobile Banner Kill

Removes the banner prompting to open reddit in the mobile app. This script only does anything on mobile browsers that support Tampermonkey

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Reddit Mobile Banner Kill
// @namespace    http://tampermonkey.net/
// @version      0.7
// @description  Removes the banner prompting to open reddit in the mobile app. This script only does anything on mobile browsers that support Tampermonkey
// @author       Zoidy
// @license      MIT
// @match        *://*.reddit.com/*
// @match        *://reddit.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @require      https://code.jquery.com/jquery-3.4.1.slim.min.js
// @grant        none
// ==/UserScript==

(function() {
    console.log("Reddit mobile app banner kill loaded!");

    //Top button on homepage
    $(".TopNav__useAppButton").hide();
    $("#get-app").hide();
    $("li.TopNav__promoButton").hide();

    var id = setInterval(function() {
        //View in app or continue in browser (version A)
        $("button.XPromoPopupRpl__actionButton:contains('Continue')").click(); //click the continue button. Should hide banner for the rest of the session
        $("div.XPromoPopupRpl").parent().hide();                               //Hide the banner in case clicking continue doesn't work
        $("div.XPromoBottomBar").hide();                                       //hide the other 'open in app' banner
        $("body").removeClass("scroll-disabled");

        //View in app or continue in browser (version B - a different popup appears sometimes)
        try{
            $("#secondary-button",
				$("xpromo-bottom-sheet",
					$("xpromo-app-selector",
						$("shreddit-async-loader",
							$("shreddit-experience-tree.theme-beta")[0].shadowRoot
						)[0].shadowRoot
					)[0].shadowRoot
				)[0].shadowRoot
            ).click();
        }catch(e){}

        //View in app or continue in browser (version B)
        try{
            $("#secondary-button",
				$("xpromo-bottom-sheet",
					$("xpromo-app-selector",
						$("shreddit-async-loader",
							$("shreddit-experience-tree.theme-beta")[0].shadowRoot
						)[0].shadowRoot
					)[0].shadowRoot
				)[0]
             ).click();
        }catch(e){}

        //See Reddit in... (new version C)
        try{
            $('button#secondary-button',
				$('xpromo-app-selector',
					$('shreddit-async-loader[paint-group="xpromo"][bundlename="app_selector"]')[0].shadowRoot
				)[0].shadowRoot
             ).click()
        }catch(e){}

        //Top button on homepage. hide again, they sometimes reappear
        $(".TopNav__useAppButton").hide();
        $("#get-app").hide();

        //Top button on child pages
        $("shreddit-async-loader[bundlename='top_button'][paint-group='xpromo']").hide();

        //"This Page looks better in the app"
        try{
            $("xpromo-bottom-bar",
				$("shreddit-async-loader[bundlename='bottom_bar_xpromo']")[0].shadowRoot
			).hide();
        }catch(e){}

        //"View Reddit in app bottom banner"
        try{
            $("#xpromo-bottom-sheet button").click();
        }catch(e){}
    }, 200);

    //keep the hiding code running for a while since things reappear.
    setTimeout(function(){
        clearInterval(id);
        console.log("Reddit mobile app banner kill ended!");
    },7000);
})();