// ==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 // @downloadURL none // ==/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(); } } })();