Print Own Code

Print the code of this user script

当前为 2023-10-27 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Print Own Code
  3. // @namespace your-namespace
  4. // @version 1.0
  5. // @description Print the code of this user script
  6. // @match *://*/*
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. 'use strict';
  12.  
  13. // Function to print the script code
  14. function printScriptCode() {
  15. const scriptElements = document.querySelectorAll('script');
  16. for (const script of scriptElements) {
  17. if (script.src === '' && script.textContent.includes('// ==UserScript==')) {
  18. console.log(script.textContent);
  19. }
  20. }
  21. }
  22.  
  23. // Call the function to print the script code
  24. printScriptCode();
  25. })();