快速复制Pixiv ID

对图片或链接双击右键(或按Alt和右键)即可复制Pixiv作品ID

  1. // ==UserScript==
  2. // @name 快速复制Pixiv ID
  3. // @name:en Fast copy Pixiv ID
  4. // @name:ja 急速にコピーPixiv ID
  5. // @description 对图片或链接双击右键(或按Alt和右键)即可复制Pixiv作品ID
  6. // @description:en Double click the right button (or press Alt + right button) on the picture or link, and you can copy the Pixiv work ID.
  7. // @description:ja 画像またはリンク上で右キー(または、alt及び右ボタン)をダブルクリックして、pixiv作品idをコピーすることができる。
  8. // @version 1.25
  9. // @namespace https://github.com/VMatrices
  10. // @author VMatrices
  11. // @include *://www.pixiv.net/*
  12. // @include *://www.pixivision.net/*
  13. // @include *://saucenao.com/*
  14. // @include *://iqdb.org/*
  15. // @icon https://www.pixiv.net/favicon.ico
  16. // @grant GM_setClipboard
  17. // @grant GM_notification
  18. // ==/UserScript==
  19.  
  20. (function() {
  21. 'use strict';
  22.  
  23. var match_rules=[
  24. /([_=:;&\-\/\.\?\d\w]+?illust_id=(\d+)(?:&|$|))/i ,
  25. /(http(?:s|):\/\/[_\-\/\.\d\w]+?\/(\d{4,})_p\d{1,4}[_\-\/\.\d\w]*)/i
  26. ];
  27. var preTime=0,
  28. preElemnt=null,
  29. baseURL=document.URL.match(/(.+)\//)[1],
  30. isEdge=navigator.userAgent.indexOf("Edge")>0;
  31.  
  32. window.addEventListener('contextmenu',function (event) {
  33. var el = event.target;
  34. if (el != null) {
  35. var nowTime=new Date().getTime();
  36. if((nowTime-preTime<500&&preElemnt==el)||event.altKey){
  37. var url,pid;
  38. var HTML=el.outerHTML;
  39. for(var i in match_rules){
  40. var results=HTML.match(match_rules[i]);
  41. if(results!=null&&results.length>1){
  42. url=results[1];
  43. pid=results[2];
  44. break;
  45. }
  46. }
  47. if(pid!=null){
  48. if(url.indexOf("http")<0){
  49. url=baseURL+url;
  50. }
  51. console.log("PID:",pid,"URL:",url);
  52. 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)/);
  53. var img=imgMatch!=null?"https://i.pximg.net/c/250x250_80_a2/img-master/img/"+imgMatch[1]+"_square1200.jpg":"https://www.pixiv.net/favicon.ico";
  54. GM_setClipboard(pid);
  55. if(isEdge){
  56. prompt('Pixiv illust ID: '+pid,pid);
  57. } else GM_notification({
  58. title:'Illust ID: '+pid,
  59. text:'https://www.pixiv.net/member_illust.php?mode=medium&illust_id='+pid,
  60. image:img,
  61. timeout: 5000
  62. });
  63. event.preventDefault();
  64. return false;
  65. }
  66. }
  67. preTime=nowTime;
  68. preElemnt=el;
  69. }
  70. });
  71.  
  72. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址