您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
readfree上传页面豆瓣信息自动填充
当前为
// ==UserScript== // @name 豆瓣信息自动填充 // @namespace http://tampermonkey.net/ // @version 0.1 // @description readfree上传页面豆瓣信息自动填充 // @author You // @match https://readfree.me/upload/diy/* // @grant GM_xmlhttpRequest // ==/UserScript== (function() { let link=$("#id_link") let link_p=link.parent() let btn=$("#write_button") btn.remove() link_p.append('<input id="write_button" type="button" value="自动填充"/>') btn=$("#write_button") btn.click(function(){ //event.preventDefault(); let url=encodeURI(link.val()) GM_xmlhttpRequest({ method: "GET", url: url, onload: function (response) { if (response.status === 200) { let data =response.response let wrapper= $(data).filter("#wrapper") let info= wrapper.get(0).querySelector("#info") $("#id_title").val(wrapper.find("h1").children("span").text()) let info_list=info.querySelectorAll(".pl") let info_val_list={} for (let i=0;i<info_list.length;i++){ info_val_list[info_list[i].innerText.replace(/ |:/g,"")]=info_list[i] } let data_list=['作者','译者','出版社','ISBN'] let authors=info_val_list[data_list[0]] $("#id_authors").val(Array.from(authors.parentNode.querySelectorAll("a")).map(function(currentValue){return currentValue.innerText}).join(",")) try{ let translators=info_val_list[data_list[1]] $("#id_translators").val(Array.from(translators.parentNode.querySelectorAll("a")).map(function(currentValue){return currentValue.innerText}).join(",")) }catch(err){ } let publisher=info_val_list[data_list[2]] $("#id_publisher").val(publisher.nextSibling.nodeValue.replace(/\n| /g,"")) let isbn13=info_val_list[data_list[3]] $("#id_isbn13").val(isbn13.nextSibling.nodeValue.match(/\d+/)) let related_info= wrapper.get(0).querySelector("#link-report") $(related_info.querySelector(".short")).remove() related_info=related_info.querySelector(".intro") let related_info_list=related_info.querySelectorAll("p") $("#id_summ").val(Array.from(related_info_list).map(function(currentValue){return currentValue.innerText}).join("\n")) let tags= wrapper.get(0).querySelectorAll("a.tag") $("#id_tags").val(Array.from(tags).map(function(currentValue){return currentValue.innerText}).join(",")+",DIY") } else{ alert("error: "+url+" "+response.status) } } }) }) //link.after('<input id="submit_button" type="submit" value="自动填充"/>') })();