Example UserScript

An example script with a proper license

  1. // ==UserScript==
  2. // @name Example UserScript
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description An example script with a proper license
  6. // @author Your Name
  7. // @match https://www.example.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. // ==UserScript==
  13. // @name Example UserScript
  14. // @namespace http://tampermonkey.net/
  15. // @version 0.1
  16. // @description An example script using @match annotation
  17. // @author You
  18. // @match https://www.example.com/*
  19. // @match https://anotherwebsite.com/*
  20. // @grant none
  21. // ==/UserScript==
  22.  
  23. (function() {
  24. 'use strict';
  25.  
  26. // This code will run on pages that match the above @match URLs
  27.  
  28. console.log("Hello, world! This script is running on:", window.location.href);
  29.  
  30. // Example action: Change background color of the page
  31. document.body.style.backgroundColor = "lightblue";
  32. })();
  33.  
  34. // ==UserScript==
  35. // @name Example UserScript with @include
  36. // @namespace http://tampermonkey.net/
  37. // @version 0.1
  38. // @description An example script using @include annotation
  39. // @author You
  40. // @include https://www.example.com/*
  41. // @include https://anotherwebsite.com/*
  42. // @grant none
  43. // ==/UserScript==
  44.  
  45. (function() {
  46. 'use strict';
  47.  
  48. // This code will run on pages that match the above @include URLs
  49.  
  50. console.log("Hello, world! This script is running on:", window.location.href);
  51.  
  52. // Example action: Change background color of the page
  53. document.body.style.backgroundColor = "lightgreen";
  54. })();
  55.