USO - add USOa button on userstyle page

Add a link to the copy of the current userstyle on uso.kkx.one

当前为 2022-06-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name USO - add USOa button on userstyle page
  3. // @namespace github.com/Procyon-b
  4. // @version 0.2
  5. // @description Add a link to the copy of the current userstyle on uso.kkx.one
  6. // @author Achernar
  7. // @match https://userstyles.org/styles/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. "use strict";
  13.  
  14. var b=document.querySelector('#top-buttons > .left');
  15.  
  16. const obs=new MutationObserver(function(muts){
  17. for (let mut of muts) {
  18. for (let n of mut.addedNodes) {
  19. b=n && n.querySelector && n.querySelector('#top-buttons > .left');
  20. if (b) {
  21. this.disconnect();
  22. setTimeout(addLink,0);
  23. return;
  24. }
  25. }
  26. }
  27. });
  28.  
  29. if (b) addLink();
  30. else obs.observe(document.body, {attributes: false, subtree: true, childList: true });
  31.  
  32. function addLink() {
  33. var L='https://uso.kkx.one/style/'+location.pathname.split('/')[2];
  34. var e=document.createElement('style');
  35. b.appendChild(e);
  36. e.innerText='#USOa {background: #39c739; color: white; text-align: center;}';
  37. e=document.createElement('a');
  38. b.appendChild(e);
  39. e.outerHTML='<a href="'+L+'" target="_blank" class="customize_button" id="USOa"><div>Install from USO&nbsp;archive</div></a>';
  40. }
  41.  
  42. })();