// ==UserScript== // @name 增强黎明版 // @namespace no1xsyzy // @version 0.1.2 // @description 增强黎明版的一些交互 // @author no1xsyzy // @match http://adnmb1.com/* // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @license Apache License, Version 2.0 (Apache-2.0); https://opensource.org/licenses/Apache-2.0 // @downloadURL none // ==/UserScript== (function() { 'use strict'; var parsedSearch = (function(s){ var m = {} s.trimLeft("?").split("&").forEach(function(kvp){ var kvl=kvp.split("=",2) m[kvl[0]]=kvl[1] }) return m })(window.location.search) // Different pages if(window.location.href.includes("doReplyThread")){ // 回复成功 console.log("ran l.26") if(!document.getElementsByClass('success')[0].innerText.includes("回复成功")){ console.log("not success?") return false } var postid=/https?:\/\/[^/]+(\/t\/\d+)/.exec(document.getElementById('href').href)[1] GM_deleteValue(postid) }else if(window.location.href.includes("/t/")){ var theinputbox = document.querySelector("textarea.h-post-form-textarea") theinputbox.value = GM_getValue(window.location.pathname, parsedSearch.r?">>No."+parsedSearch.r+"\n":"") var updateInputboxValue = function(){ GM_setValue(window.location.pathname, theinputbox.value) } theinputbox.addEventListener("change", updateInputboxValue) document.querySelectorAll("a.h-threads-info-id").forEach(function(m){ m.addEventListener("click", function(e){ if(theinputbox.value.length > 0 && !theinputbox.value.endsWith("\n")){ theinputbox.value += "\n" } theinputbox.value += ">>"+m.innerText+"\n" updateInputboxValue() console.log(e) e.preventDefault() }) }) } })();