// ==UserScript== // @name JS practice for S1 // @namespace http://tampermonkey.net/ // @version 0.143 // @description JS练习脚本 // @author Lery // @include *://*.saraba1st.com/2b/* // @include *://*.stage1st.com/2b/* // @include *://*.stage1.cc/2b/* // @grant GM_xmlhttpRequest // @require https://cdn.bootcss.com/store.js/1.3.20/store+json2.min.js // @downloadURL none // ==/UserScript== //自动对旧链接进行修改跳转 let pattern0 = new RegExp('^([^.]+\\.)?(saraba1st|stage1(st)?)\\.(com|cc)/2b/read'); if(pattern0.test(document.URL)){ location.href="https://" + location.hostname + "/2b/thread-" + location.href.split("tid-")[1].split(".html")[0] + "-1-1.html"; } //修改网页标题后缀 let pattern1 = new RegExp('^(?:论坛|.+?)(?=(?:论坛)?(?: - Stage1st)? - stage1\\/s1 游戏动漫论坛$)'); if(pattern1.test(document.title)){ document.title = pattern1.exec(document.title) + " - STAGE1"; } //自动签到 if(document.querySelector('a[href*="study_daily_attendance-daily_attendance.html"]')){//检测到签名链接 ajaxget(document.querySelector('a[href*="study_daily_attendance-daily_attendance.html"]').href);//后台获取链接→进行签名 document.querySelector('a[href*="study_daily_attendance-daily_attendance.html"] + .pipe').remove();//删除链接旁的分隔线 document.querySelector('a[href*="study_daily_attendance-daily_attendance.html"]').remove();//删除链接 } //点击更换漫区随机图 if(document.querySelector('img[src^="http://ac.stage3rd.com/S1_ACG_randpic.asp"]')){ let changepic = document.querySelector('img[src^="http://ac.stage3rd.com/S1_ACG_randpic.asp"]'); changepic.onclick = function(){ document.querySelector('img[src^="http://ac.stage3rd.com/S1_ACG_randpic.asp"]').src="http://ac.stage3rd.com/S1_ACG_randpic.asp"+"?t=" + Math.random(); }; } //记录位置 var timer = null; window.addEventListener('scroll', function () { if (typeof timer === 'number') { clearTimeout(timer); } timer = setTimeout(function () { //添加onscroll事件处理 }, 500); }, false); //自定义快捷入口 function createLink(name, addr) { let node = document.createElement("li"); if(window.location.pathname == "/2b/" + addr) node.className = "a"; let link = document.createElement("a"); link.setAttribute("href",addr); link.setAttribute("hidefocus","true"); link.appendChild(document.createTextNode(name)); node.appendChild(link); return node; } //找到导航栏位置 document.getElementsByTagName("h2")[0].childNodes[0].setAttribute("href", "./forum.php"); var linkList = document.getElementById("nv").getElementsByTagName("ul")[0]; //增加快捷入口 GM_xmlhttpRequest({ method: "GET", url: "https://" + location.hostname + "/2b/forum.php?mod=ajax&action=forumjump",//获取快捷导航栏板块页面 onload: function(data){ //识别获取收藏板块列表 let pattern = new RegExp('