Inject useful scripts

Inject some of your useful scripts to window

  1. // ==UserScript==
  2. // @name Inject useful scripts
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-04-28
  5. // @description Inject some of your useful scripts to window
  6. // @author Iris Xe
  7. // @match *://*.baidu.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=baidu.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. // Add your scripts name here:
  16. const entry = {
  17. query,
  18. };
  19. // Add your scripts implament here:
  20. function query(selector) {
  21. if (!selector) {
  22. return;
  23. }
  24. const results = document.querySelectorAll(selector);
  25. if (results.length && results.length === 1) {
  26. console.log(results[0]);
  27. } else {
  28. console.log(results);
  29. }
  30. }
  31.  
  32. // Injector
  33. Object.keys(entry).forEach(key => {
  34. window[key] = entry[key];
  35. });
  36. })();

QingJ © 2025

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