No Tiexue Post2

铁血论坛链接替换'post2'为‘post’,不用再为满屏广告烦恼,直接跳转查看原帖

当前为 2016-12-22 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name               No Tiexue Post2
// @name:zh-CN         替换铁血post2
// @namespace          daizp
// @version            0.2.5
// @description        铁血论坛链接替换'post2'为‘post’,不用再为满屏广告烦恼,直接跳转查看原帖
// @author             daizp
// @match              http://www.tiexue.net/*
// @match              http://bbs.tiexue.net/*
// @grant              none
// ==/UserScript==

(function () {
    'use strict';
    switch (location.host) {
        case "www.tiexue.net":
            no_www_post2();
            break;
        case "bbs.tiexue.net":
            no_bbs_post2();
            no_bbs_ad();
            break;
    }
    //替换主页post2为post
    function no_www_post2(){
        var i=0;
        var pic_obj = document.getElementById("pics"+i.toString());
        while(pic_obj){
            pic_obj.innerHTML = pic_obj.innerHTML.replace(/post2/g,"post");
            pic_obj = document.getElementById("pics"+(i++).toString());
        }
    }
    //替换论坛post2为post
    function no_bbs_post2(){
        var pathname = location.pathname;
        if(pathname.substr(0,6) == "/post2"){
            window.location = "post" + pathname.substr(6);
        }
    }
    //删除bbs广告
    function no_bbs_ad(){
        //删除左边广告
        var left_ad = document.getElementById("Baidu_BBSPostNormalV3ContentLeftAD1");
        if(left_ad){
            left_ad.remove();
        }
    }
})();