Phixiv Share

Add Phixiv Share button to pixiv

目前为 2024-03-25 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Phixiv Share
  3. // @namespace https://github.com/gjing/phixiv-share
  4. // @version 1.0
  5. // @description Add Phixiv Share button to pixiv
  6. // @author gjing
  7. // @match https://www.pixiv.net/*
  8. // @run-at document-idle
  9. // @license MIT
  10. // ==/UserScript==
  11. (function() {
  12. 'use strict';
  13. const intv = setInterval(function() {
  14. const nav_bar = document.getElementsByClassName("sc-181ts2x-0");
  15. if (nav_bar.length == 0) {
  16. return false;
  17. }
  18. clearInterval(intv);
  19. load_icon()
  20. }, 100);
  21.  
  22. function load_icon() {
  23. const link = window.location.href.replace("pixiv", "phixiv");
  24. const element = document.getElementsByClassName("sc-181ts2x-0")[0];
  25. const div_string = '<div class="sc-181ts2x-7"><button type="button" class="y35SzDmKENoCKvur"><span class="Gi9zOhEDaI9fmUNA">PHIX</span></button></div>';
  26. const div = document.createElement('div');
  27. div.innerHTML = div_string;
  28. div.style.paddingRight = '10px';
  29. div.onclick = function() {
  30. navigator.clipboard.writeText(link);
  31. }
  32. element.appendChild(div);
  33. }
  34. })();