激战2维基辅助 一键复制API ID

在激战2维基百科上,一键复制技能、特性和物品等的 ID 代码

  1. // ==UserScript==
  2. // @name 激战2维基辅助 一键复制API ID
  3. // @name:en API ID copy tool on wiki.guildwars2.com
  4. // @namespace https://gf.qytechs.cn/scripts/413426
  5. // @version 1.1
  6. // @description 在激战2维基百科上,一键复制技能、特性和物品等的 ID 代码
  7. // @description:en add a button to copy API ID code of items, skills, traits on wiki.guildwars2.com
  8. // @icon https://wiki.guildwars2.com/favicon.ico
  9. // @author 买本子@bilibili
  10. // @run-at document-end
  11. // @require https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js
  12. // @match https://wiki.guildwars2.com/wiki/*
  13.  
  14. // @grant none
  15. // @license GPL-v3
  16. // ==/UserScript==
  17.  
  18. /* global $ */
  19.  
  20. // 作者简介
  21. // 买本子@bilibili
  22.  
  23. // 如有 Bug 请在 gf.qytechs.cn 我的脚本评论区进行反馈。
  24. // 私人脚本可联系我付费定制,QQ:610915518
  25.  
  26. // 版权申明
  27. // 本脚本为 买本子@bilibili 原创,未经作者授权禁止转载,禁止转载范围包括但不仅限于:贴吧、NGA论坛等。
  28.  
  29. $('a[rel="nofollow"][class="external text"]').each(function(){
  30. if ($(this).attr("href") && $(this).attr("href").startsWith("https://api.guildwars2.com/v2") ) {
  31. var iidd = $(this).attr("href").toString().split("ids=", 2)[1].split("&", 2)[0];
  32. var text_copy_items = '<button type="button" onclick=copyBtnItems('+iidd +')>copy 物品</button>';
  33. var text_copy_traits = '<button type="button" onclick=copyBtnTraits('+iidd +')>copy 特性</button>';
  34. var text_copy_skills = '<button type="button" onclick=copyBtnSkills('+iidd +')>copy 技能</button>';
  35. var text_copy = '<button type="button" onclick=copyBtnID('+iidd +')>copy '+iidd+'</button>';
  36.  
  37. $(this).after(text_copy_traits);
  38. $(this).after(text_copy_skills);
  39. $(this).after(text_copy_items);
  40. $(this).after(text_copy);
  41. };
  42. });
  43.  
  44.  
  45. var ctc = `<script>
  46.  
  47. function copyBtnID(iidd) {
  48. navigator.clipboard.writeText(iidd);
  49. }
  50.  
  51. function copyBtnItems(iidd) {
  52. var stringText = '<span data-armory-embed="items" data-armory-ids="iidd" data-armory-inline-text="wiki" data-armory-size="24" />'.replaceAll("iidd", iidd);
  53. navigator.clipboard.writeText(stringText);
  54. }
  55.  
  56. function copyBtnTraits(iidd) {
  57. var stringText = '<span data-armory-embed="traits" data-armory-ids="iidd" data-armory-inline-text="wiki" data-armory-size="24" />'.replaceAll("iidd", iidd);
  58. navigator.clipboard.writeText(stringText);
  59. }
  60.  
  61. function copyBtnSkills(iidd) {
  62. var stringText = '<span data-armory-embed="skills" data-armory-ids="iidd" data-armory-inline-text="wiki" data-armory-size="24" />'.replaceAll("iidd", iidd);
  63. navigator.clipboard.writeText(stringText);
  64. }
  65.  
  66. function copyToClipboard(text) {
  67. if (window.clipboardData && window.clipboardData.setData) {
  68. // Internet Explorer-specific code path to prevent textarea being shown while dialog is visible.
  69. return clipboardData.setData("Text", text);
  70.  
  71. }
  72. else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
  73. var textarea = document.createElement("textarea");
  74. textarea.textContent = text;
  75. textarea.style.position = "fixed"; // Prevent scrolling to bottom of page in Microsoft Edge.
  76. document.body.appendChild(textarea);
  77. textarea.select();
  78. try {
  79. return document.execCommand("copy"); // Security exception may be thrown by some browsers.
  80. }
  81. catch (ex) {
  82. console.warn("Copy to clipboard failed.", ex);
  83. return false;
  84. }
  85. finally {
  86. document.body.removeChild(textarea);
  87. }
  88. }
  89. }
  90. </script>`
  91.  
  92. $('#globalWrapper').after(ctc);

QingJ © 2025

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