appendShadow

💜

  1. // jshint esversion: 6
  2. // eslint-disable-next-line
  3. // ==UserScript==
  4. // @name appendShadow
  5. // @namespace https://dniness.github.io/
  6. // @version 0.03
  7. // @description 💜
  8. // @author Dniness
  9. // @match *://*/*
  10. // @icon data:image/svg+xml,<svg width='64' height='64' fill='none' xmlns='http://www.w3.org/2000/svg'><circle cx='32' cy='32' r='32' fill='darkgray'/></svg>
  11. // @grant none
  12. // @run-at document-body
  13. // @license MPL2.0
  14. // ==/UserScript==
  15.  
  16.  
  17. (document.appendShadow=(func,name)=>{
  18. 'use strict';
  19. const mode = name?'open':'closed';
  20. [,name,func]=(func+'').match(/([^ =]+)[^{]+\{(.+)\}$/);
  21. name = name.replace(/([A-Z])/g,"-$1").toLowerCase();
  22. customElements.define(name, class extends HTMLElement {
  23. constructor() {
  24. super();
  25. new Function(func).call(this.attachShadow({mode}));
  26. }
  27. })
  28. document.body.appendChild(document.createElement(name));
  29. })(exampleMonkeyShadow=>{this.appendChild(document.createElement('h2'))});

QingJ © 2025

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