Greasy Fork

Greasy Fork is available in English.

吾爱破解自动切换宽窄版(去广告)

吾爱破解(www.52pojie.cn)自动切换窄版,去除广告

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         吾爱破解自动切换宽窄版(去广告)
// @icon         https://www.52pojie.cn/favicon.ico
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  吾爱破解(www.52pojie.cn)自动切换窄版,去除广告
// @author       The_Soloist
// @match        https://www.52pojie.cn/*
// @grant        GM_addStyle
// ==/UserScript==

(function () {
    'use strict';

    const css = `
      /* 帖内广告:水平 + 竖直 */
      .dnch_eo_pt, .dnch_eo_pr{ display: none !important; }

      /* 用户签名 + 签名下的提示 */
      .sign, .dnch_eo_pb{ display: none !important; }

      /* 底部广告 */
      .dnch_eo_f, .dnch_eo_mu{ display: none !important; }
    `

    // css去除广告
    try {
        GM_addStyle(css)
    } catch (e) {
        console.log('脚本失效,刷新后重试。', e)
    }

    // 模拟点击
    var url = document.URL;
    var switch_width_title = document.getElementById('switchwidth').getAttribute("title");
    if (url == 'https://www.52pojie.cn/' || url.indexOf('forum-') != -1 || url.indexOf('forum.php') != -1 || url.indexOf('misc.php') != -1 || url.indexOf('home.php') != -1) {
        if (switch_width_title == "切换到窄版") { // 网站目录等 切换到窄版
            document.getElementById("switchwidth").click();
        }
    }
    if (url.indexOf('thread-') != -1) {
        if (switch_width_title == "切换到宽版") { // 帖子等 切换到宽版
            document.getElementById("switchwidth").click();
        }
    }


})();