Pixiv显示百科按钮

显示一个打开Pixiv百科页面的按钮

  1. // ==UserScript==
  2. // @name Pixiv显示百科按钮
  3. // @description 显示一个打开Pixiv百科页面的按钮
  4. // @namespace moe.cangku.mengzonefire
  5. // @version 1.0.4
  6. // @author mengzonefire
  7. // @license MIT
  8. // @contributionURL https://afdian.net/@mengzonefire
  9. // @match *://www.pixiv.net/*
  10. // @require https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js
  11. // @run-at document-start
  12. // ==/UserScript==
  13. !(() => {
  14. "use strict";
  15. const htmlTag = "div.sc-1973m3p-0";
  16. var tag = "";
  17. function addBtn() {
  18. let html_tag = $(htmlTag);
  19. if (html_tag.length) {
  20. let className = html_tag[0].children[0].className;
  21. let htmlBtn = `<button id="mzf_dic_btn" aria-disabled="false" class="${className}" onclick="window.open('https://dic.pixiv.net/a/${tag}','_self')">Pixiv百科全书</button>`;
  22. html_tag.before(htmlBtn);
  23. } else setTimeout(addBtn, 100);
  24. }
  25. function start() {
  26. let MutationObserver =
  27. window.MutationObserver ||
  28. window.WebKitMutationObserver ||
  29. window.MozMutationObserver;
  30. let observer = new MutationObserver(urlChangeHandler);
  31. observer.observe($("head > title")[0], {
  32. childList: true,
  33. });
  34. }
  35. function urlChangeHandler() {
  36. tag = window.location.href.match(/\/tags\/([^/]+)/);
  37. if (tag) {
  38. tag = tag[1];
  39. console.log(`match tag: ${decodeURIComponent(tag)}`);
  40. addBtn();
  41. }
  42. }
  43. jQuery(start);
  44. })();

QingJ © 2025

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