您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Updates threads automatically if the ticker is open. Requires "Enhanced Ticker" 3.32 or upwards.
当前为
// ==UserScript== // @name Enhanced Ticker: Autoupdate threads // @namespace MrBrax // @description Updates threads automatically if the ticker is open. Requires "Enhanced Ticker" 3.32 or upwards. // @include https://facepunch.com/showthread.php?* // @version 0.11 // @grant GM_addStyle // ==/UserScript== function timeSince(date) { var seconds = Math.floor((new Date() - date) / 1000); var interval = Math.floor(seconds / 31536000); if (interval > 1) { return interval + " Years"; } interval = Math.floor(seconds / 2592000); if (interval > 1) { return interval + " Months"; } interval = Math.floor(seconds / 86400); if (interval > 1) { return interval + " Days"; } interval = Math.floor(seconds / 3600); if (interval > 1) { return interval + " Hours"; } interval = Math.floor(seconds / 60); if (interval > 1) { return interval + " Minutes"; } return Math.floor(seconds) + " seconds"; } GM_addStyle(".au_bar { background: #cce; border: 1px solid #777; border-bottom-width: 0; clear: both; display: block; font: 12px Tahoma; padding: 4px; width: 100%; box-sizing: border-box; }"); var thread = location.href.match(/\?t=([0-9]+)/); var paginator = document.getElementById("yui-gen1"); var plist = document.getElementById("posts"); if( paginator ){ var s = paginator.innerHTML.trim().match(/Page ([0-9]+) of ([0-9]+)/); console.log( s[1], s[2], s[1] == s[2] ); if(s[1] != s[2]){ var au_info = document.createElement("div"); au_info.className = "au_bar"; au_info.innerHTML = "<strong>Auto updater not running, go to the last page.</strong>"; plist.appendChild(au_info); return; } } var title = document.title; var newposts = 0; document.title = "[" + newposts + "] " + title; var au_info = document.createElement("div"); au_info.className = "au_bar"; au_info.innerHTML = "<strong>Auto updater start</strong>"; plist.appendChild(au_info); function updateTime(a){ var t = document.querySelectorAll(".date"); for(i in t){ var d = new Date( t[i].title ); t[i].innerHTML = timeSince( d.getTime() ) + " Ago"; } if(!a) setTimeout( updateTime, 10000 ); } updateTime(); var storageHandler = function (e) { if(e.key == "ETicker_LastPost"){ var d = e.newValue.split("."); if(d[0] == thread[1]){ var url = "https://facepunch.com/showthread.php?t=" + d[0] + "&p=" + d[1]; console.log("Update thread", thread[1], url); var xhr = new XMLHttpRequest(); xhr.open("GET", url, true); xhr.responseType = "document"; xhr.onreadystatechange = function (){ if (xhr.readyState == 4 && xhr.status == 200){ var data = xhr.responseXML; console.log(data); var newp = data.getElementById("post_" + d[1]); if(newp){ if(newp.parentNode.childNodes[1] == newp){ var s = document.createElement("div"); s.className = "au_bar"; s.innerHTML = "<strong>New page</strong>"; plist.appendChild(s); console.log("new page"); } plist.appendChild(newp); } newposts++; document.title = "[" + newposts + "] " + title; updateTime(true); } }; xhr.send(); } } }; window.addEventListener("storage", storageHandler, false);
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址