古诗文网增强

一个增强古诗文网功能的插件

目前為 2023-05-28 提交的版本,檢視 最新版本

// ==UserScript==
// @name         古诗文网增强
// @namespace    http://tampermonkey.net/
// @version      0.6
// @description  一个增强古诗文网功能的插件
// @author       haozexu
// @match        https://*.gushiwen.cn/*
// @icon         https://gitee.com/haozexu/hzx-scripts/raw/master/LogoHzx2023.png
// @grant        none
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// @license      GPL v3.0
// ==/UserScript==

(function() {
    'use strict';
    function showErwema(){
        console.log("")
    }
    if(window.showErweima!=undefined){
    var nsfun = new Function('return ' + window.showErweima.toString())();
    window.showErweima=showErwema;
    var lnk = document.createElement("a");
    var node = document.createTextNode("登录");
    lnk.appendChild(node);
    lnk.onclick=nsfun;console.log("[HzxScript]Login popup blocked");
    var element = document.getElementsByClassName("son1")[0];
    element.appendChild(lnk);
    }
    $("div.right").ready(function(){
    $("div.abcd").remove();$(".juzioncont").remove();
    $("div#btmwx").remove();
    $("div.right").style="background-color:#F0EFE2";
    var text="<div style=\"background-color:#F0EFE2;margin-top:20px;padding-top:20px;padding-bottom:20px;text-align:center\"><h1 style=\"font-size:x-large\">HzxScript已关闭广告</h1><br><p>HzxScript:古诗文网优化工具 - <a href=\"https://greasyfork.org/zh-CN/scripts/466763-%E5%8F%A4%E8%AF%97%E6%96%87%E7%BD%91%E5%A2%9E%E5%BC%BA\">haozexu</a></p></div>"
    $("div.main3 div.right").append(text);
    //var backtop_button="<button id=\"scrollback\" style=\"position:fixed;right:10px;bottom:10px;background-color:gray;height:30px;width:30px\">回到顶部</button>";
    var btn = document.createElement("button");
    var node = document.createTextNode("回到顶部");
    btn.appendChild(node);
    btn.onclick=function(){scrollTo(0,0);};btn.style="position:fixed;right:10px;bottom:10px;background-color:gray;height:50px;width:50px";
    $("div.main3").append(btn);
    console.log("[HzxScript]Ads blocked");
    console.log("[HzxScript]Sollback button added");
    })
    var nodelist=document.getElementsByTagName('a');
    console.log("[HzxScript]"+nodelist);
    function ZiliaoShowCallback(nodethis){
          //console.log('HzxScript:'+nodethis.href);
          if(nodethis.href.includes("javascript:ziliaoShow")){
                eval(nodethis.href);//自动展开所有
          }
    }
    function ZiliaoCloseCallback(nodethis){
          if(nodethis.href.includes("javascript:ziliaoClose")){
                eval(nodethis.href);//自动展开所有
          }
    }
    var btn_show = document.createElement("button");
    var node_text = document.createTextNode("全部展开");
    btn_show.appendChild(node_text);
    btn_show.style="position:fixed;right:10px;bottom:80px;background-color:gray;height:50px;width:50px;display:block;";
    var btn_show2 = document.createElement("button");
    var node_text2 = document.createTextNode("全部折叠");
    btn_show2.appendChild(node_text2);
    btn_show2.style="position:fixed;right:10px;bottom:80px;background-color:gray;height:50px;width:50px;display:none;";
    var button_state=true;
    btn_show.onclick=function(){
        if(button_state){
              button_state=false;
              btn_show.style['display']='none';
              btn_show2.style['display']='block';
              for(var i=0;i<nodelist.length;i++){
                  //console.log('HzxScript:'+nodelist[i].href);
                  ZiliaoShowCallback(nodelist[i]);
              }
        }else{
              button_state=true;
              btn_show.style['display']='block';
              btn_show2.style['display']='none';
              for(var j=0;j<nodelist.length;j++){
                  //console.log('HzxScript:'+nodelist[j].href);
                  ZiliaoCloseCallback(nodelist[j]);
              }
        }
    };
    btn_show2.onclick=btn_show.onclick;
    $("div.main3 div.right").append(btn_show2);
    $("div.main3 div.right").append(btn_show);


})();