您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
JS练习脚本
当前为
- // ==UserScript==
- // @name JS practice for S1
- // @namespace http://tampermonkey.net/
- // @version 0.121
- // @description JS练习脚本
- // @author Lery
- // @include /^([^\.]+\.)?(saraba1st|stage1(st)?)\.(com|cc)/2b/.*
- // @grant GM_xmlhttpRequest
- // @require https://cdn.bootcss.com/store.js/1.3.20/store+json2.min.js
- // ==/UserScript==
- //自动对旧链接进行修改跳转
- var 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"
- }
- //修改网页标题后缀
- var 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"]')){
- var 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();
- };
- }
- //自定义快捷入口
- function createLink(name, addr) {
- var node = document.createElement("li");
- if(window.location.pathname == "/2b/" + addr)
- node.className = "a";
- var 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){
- pattern3 = new RegExp('<div id="flsrchdiv">[\\s\\S]+(?=<script type)');
- var xmldata = pattern3.exec(data.response);
- var parser = new DOMParser();
- doc = parser.parseFromString(xmldata, "application/xml");
- var forumItems = doc.querySelectorAll('.jump_bdl li:nth-child(3) p a');
- /*删除原快捷入口*/
- while(linkList.firstChild) {
- linkList.removeChild(linkList.firstChild);
- }
- /*生成新快捷入口*/
- if(forumItems.length >= 1){
- var pattern4 = new RegExp('.*?(?=论坛|$)');
- for(var i = 0; i < forumItems.length; i++){
- var item = forumItems[i];
- var itemText = pattern4.exec(item.textContent);
- var href = item.getAttribute('href');
- linkList.appendChild(createLink(itemText,href));
- }
- }
- /*在此处添加您的自定义快捷入口,格式为 linkList.appendChild(createLink("入口名称","主域名/2b/后面的地址")); ,参考下面提供的默认项*/
- linkList.appendChild(createLink("抹布","home.php?mod=space&do=friend&view=blacklist"));
- linkList.appendChild(createLink("客户端","thread-1486168-1-1.html"));
- linkList.appendChild(createLink("我的回复","forum.php?mod=guide&view=my&type=reply"));
- }
- });
- //记录并显示上次阅读的界面
- var pattern5 = new RegExp('forum\\.php\\?mod=(forumdisplay|viewthread)|(forum|thread)(-[0-9]+)+\\.html');
- if(pattern5.test(document.URL)){
- if (!store.enabled) {
- alert('浏览器不支持本地缓存或开启了私隐模式,功能将失效。');
- }else{
- var lastread = store.get('lastread') ? store.get('lastread') : {};
- if(unsafeWindow.tid){
- var page = document.querySelector('#pgt > div > div > strong');
- page = page ? page.textContent : 1;
- lastread[unsafeWindow.tid] = page;
- store.set('lastread', lastread);
- }else{
- var table = document.getElementsByName('moderate')[0].children[2];
- if(table) {
- var tbodys = table.getElementsByTagName('tbody');
- for(i = 0;i < tbodys.length;i++) {
- var tbody = tbodys[i];
- var [ordertype, tid] = tbody.id.split('_');
- if(tid){
- var page = lastread[tid];
- if(page){
- var ele = document.createElement('a');
- ele.style.color = '#C03322';
- ele.style.fontWeight = 'bold';
- ele.style.padding = '1px 3px';
- ele.style.border = '1px solid #C03322';
- ele.style.borderRadius = '4px';
- ele.text = '回第' + page + '页';
- var prevpage = document.querySelector('#pgt > div > strong');
- prevpage = prevpage ? prevpage.textContent : 1;
- if(document.querySelector('#' + tbody.id + ' a').href.indexOf("forum.php")!=-1){
- ele.href = 'forum.php?mod=viewthread&tid=' + tid + '&extra=page%3D' + prevpage + '&page=' + page;
- }else{
- ele.href = 'thread-' + tid + '-' + page + '-' + prevpage + '.html';
- }
- document.querySelector('#' + tbody.id + ' > tr > th').appendChild(ele);
- }
- }
- }
- }
- }
- }
- }