USO - add USOa button on userstyle page

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

当前为 2023-02-01 提交的版本,查看 最新版本

// ==UserScript==
// @name         USO - add USOa button on userstyle page
// @namespace    github.com/Procyon-b
// @version      0.3
// @description  Add a link to the copy of the current userstyle on uso.kkx.one
// @author       Achernar
// @match        https://userstyles.org/styles/*
// @grant        none
// ==/UserScript==

(function() {
"use strict";

var b=null;

function add() {
  if (document.getElementById('USOa')) return;
  b=document.querySelector('#top-buttons > .left') || document.querySelector('#buttons') || document.querySelector('div[class^="style-details_top_"]');
  
  const obs=new MutationObserver(function(muts){
    for (let mut of muts) {
      for (let n of mut.addedNodes) {
        b=n && n.querySelector && ( n.querySelector('#top-buttons > .left') || n.querySelector('#buttons') || n.querySelector('div[class^="style-details_top_"]') );
        if (b) {
          this.disconnect();
          setTimeout(addLink,0);
          return;
          }
        }
      }
    });
  
  if (b) addLink();
  else obs.observe(document.body, {attributes: false, subtree: true, childList: true });
  }

add();

window.addEventListener('resize', function(){
  setTimeout(add,0);
  })

function addLink() {
  if (document.getElementById('USOa')) return;
  var L='https://uso.kkx.one/style/'+location.pathname.split('/')[2],
    r=document.querySelector('div[class^="style-details_top_"]'),
    e=document.createElement('style');
  b.appendChild(e);
  e.innerText='.upgradeButton {margin-right: 11px;} #USOa {background: #39c739; color: white; text-align: center; order: 9; width: unset; padding: 0 1em; border-radius: 24px; border: none;} #USOa a {color: inherit; line-height: 1.3em}';
  if (r) {
    e.innerText+='div[class^="style-details_top_"] {position:relative;} #USOa {position:absolute; top:5em; right:0px; z-index:9999;}';
    }
  e=document.createElement('div');
  b.appendChild(e);
  e.outerHTML='<div class="customize_style_button NOuninstall_stylish_style_button" id="USOa"><a href="'+L+'" class="oocustomize_button_text" target="_blank">Install&nbsp;from<br>USO&nbsp;archive</a></div>';
}

})();

QingJ © 2025

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