Basic Functions (For userscripts)

Useful functions for myself

目前為 2023-01-30 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/456034/1143733/Basic%20Functions%20%28For%20userscripts%29.js

  1. // Append a style text to document(<head>) with a <style> element
  2. // arguments: css | parentElement, css | parentElement, css, attributes
  3. function addStyle() {
  4. // Get arguments
  5. const [parentElement, css, attributes] = parseArgs([...arguments], [
  6. [2],
  7. [1,2],
  8. [1,2,3]
  9. ], [document.head, '', {}]);
  10.  
  11. // Make <style>
  12. const style = $CrE("style");
  13. style.textContent = css;
  14. for (const [name, val] of Object.entries(attributes)) {
  15. style.setAttribute(name, val);
  16. }
  17.  
  18. // Append to parentElement
  19. parentElement.appendChild(style);
  20. }

QingJ © 2025

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