TvTroper

Blocking ads and popup on TvTropes.org

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name     TvTroper
// @namespace tvtroper_1773095933
// @version  1.2
// @grant    none
// @author 	 LuaMaria (GreasyFork Version)
// @include	 *://tvtropes.org/*
// @description Blocking ads and popup on TvTropes.org
// @run-at 	 document-end
// @icon		https://assets.tvtropes.org/img/icons/apple-icon-180x180.png
// @license   LGPL-3.0-or-later
// ==/UserScript==

/*
  This program is free software: 
  you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, 
  either version 3 of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful, 
  but WITHOUT ANY WARRANTY; 
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 

  See the GNU Lesser General Public License for more details.
  < https://www.gnu.org/licenses/lgpl-3.0.html >. 
*/


//Last Update = March 18, 2026

'use strict';

const init = '##TVTroper is Active!';
console.warn(init);
//alert(init);

function id(str){
    return document.getElementById(str);
}

function sa(str){
    return document.querySelectorAll(str); 
}

const old_content = id('main-entry');

console.clear();

function blast(){
    //remove that pesky anti ad-block
    setTimeout( function(){
	console.clear();
	console.warn('restored', old_content);
	id('main-entry').innerHTML = old_content.innerHTML;
    }, 1000);

    //remove that sidebar ad
    id('stick-cont').remove();
    const sidebar_ad_class = '.tvtropes-ad-unit';
    const cursed_ad = sa(sidebar_ad_class);
    cursed_ad.forEach( s => {
	alert(s);
	console.log(s);
	s.style.display = 'none';
    });
}

blast();
let checking_counter = 0;
let checking_max_retries = 10;
const keep_checking = setInterval( function(){
    const anti_adblock = document.getElementById('adblock_title');
    if(anti_adblock){
	console.warn('they block you');
	blast();
	return;
    }else{
   	console.warn('you bypassed it hehe');
    }
    
    checking_counter ++;
    if(checking_counter > checking_max_retries){
	console.clear();
   	clearInterval(keep_checking);
	console.warn("Unblocking is done!");
    }
}, 1000);