// ==UserScript== // @name 快速复制Pixiv ID // @name:en Fast copy Pixiv ID // @name:ja 急速にコピーPixiv ID // @description 对图片或链接双击右键即可复制Pixiv作品ID // @description:en Double click the right button on image or link to copy Pixiv works ID. // @description:ja 画像やリンクダブルクリックに右ボタンでコピーPixiv作品ID // @version 1.21 // @namespace https://github.com/VMatrices // @author VMatrices // @include *://www.pixiv.net/* // @include *://www.pixivision.net/* // @include *://saucenao.com/* // @include *://iqdb.org/* // @icon https://www.pixiv.net/favicon.ico // @grant GM_setClipboard // @grant GM_notification // @downloadURL none // ==/UserScript== (function() { 'use strict'; var match_rules=[ /\"([_=:;&\-\/\.\?\d\w]+?illust_id=(\d+)(?:&|$|))\"/ , /\"(http(?:s|):\/\/[_\-\/\.\d\w]+?\/(\d{4,})_p\d{1,4}[_\-\/\.\d\w]*)\"/ ]; var preTime=0; var preElemnt=null; var baseURL=document.URL.match(/(.+)\//)[1]; var getPixivID=function (event) { var el = event.target; if (el != null) { var nowTime=new Date().getTime(); if(nowTime-preTime<500&&preElemnt==el){ var url,pid; var HTML=el.outerHTML; for(var i in match_rules){ var results=HTML.match(match_rules[i]); if(results!=null&&results.length>1){ url=results[1]; pid=results[2]; break; } } if(pid!=null){ if(url.indexOf("http")<0){ url=baseURL+url; } console.log("URL:",url,"PID:",pid); var imgMatch=el.outerHTML.match(/http(?:s|):\/\/i\.pximg\.net\/\w\/[\w\d_]+?\/img-master\/img\/((?:\d+\/){6,}\d{3,}_p\d+)_\w+\d{3,}\.(?:jpg|png)/); var img=imgMatch!=null?"https://i.pximg.net/c/128x128/img-master/img/"+imgMatch[1]+"_square1200.jpg":"https://www.pixiv.net/favicon.ico"; GM_setClipboard(pid); GM_notification({ title:"Illust ID: "+pid, text:url, image:img, timeout: 5000 }); return false; } } preTime=nowTime; preElemnt=el; } }; document.oncontextmenu=getPixivID; setTimeout(function(){ //防止其他插件覆盖掉该事件 document.oncontextmenu=getPixivID; },3000); })();