古诗文网增强

屏蔽古诗文网登录(不可用)弹窗,移除侧边广告,自动展开折叠的文本(可选择仅展开译文或全部展开)

目前為 2022-12-09 提交的版本,檢視 最新版本

// ==UserScript==
// @name         古诗文网增强
// @namespace    https://github.com/tfia
// @version      0.2
// @description  屏蔽古诗文网登录(不可用)弹窗,移除侧边广告,自动展开折叠的文本(可选择仅展开译文或全部展开)
// @author       RhDu
// @match        https://so.gushiwen.cn/*
// @icon         https://www.google.com/s2/favicons?domain=https://so.gushiwen.cn
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_notification
// ==/UserScript==

var id;
var isTranslationOnly = GM_getValue("isTranslationOnly", false);
function registerMenuCommand()
{
    if(isTranslationOnly == false) id=GM_registerMenuCommand("❌ 仅自动展开译文", reverseTranslation, "t");
    else id=GM_registerMenuCommand("✅ 仅自动展开译文", reverseTranslation, "t");
}

function reverseTranslation()
{
    GM_setValue("isTranslationOnly", !isTranslationOnly);
    isTranslationOnly = GM_getValue("isTranslationOnly", false);
    GM_unregisterMenuCommand(id);
    registerMenuCommand();
    GM_notification({text: `功能已经更改 点击刷新网页生效`, timeout: 3500, onclick: function(){location.reload();}});
}

(function()
{
    'use strict';
    //添加菜单选项
    registerMenuCommand();
    //移除登录(不可用)弹窗
    var object = document.getElementById('hide-center2');
    if (object != null)
    {
        object.parentNode.removeChild(object);
    }

    //消除侧边广告
    document.getElementsByClassName('right')[1].remove();
    //自动展开所有折叠的文本
    if(isTranslationOnly == true) $("a:contains(展开)")[0].click();
    else
    {
        var arr = document.querySelectorAll("a");
        //console.log(arr);
        for(var i=0;i < arr.length;i++)
        {
            $("a:contains(展开)")[i].click();
        }
    }


})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址