Rainbow Highlight

change the highlight color on web pages

  1. // ==UserScript==
  2. // @name Rainbow Highlight
  3. // @namespace *://*/*
  4. // @version 0.2
  5. // @description change the highlight color on web pages
  6. // @author crisxh
  7. // @match *://*/*
  8. // @icon https://www.google.com/s2/favicons?domain=w3schools.com
  9. // @grant GM_addStyle
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. let mainBox=document.querySelector("html");
  16. mainBox.addEventListener("mousedown",function(){
  17. let rainbow=["#e994b0","#fdd68e","#f5f573","#aee7ae","#bdbdf7","#9e78b9","#ca62ca"];
  18.  
  19. let randomColor=rainbow[Math.floor(Math.random()*rainbow.length)];
  20. GM_addStyle("::selection{background-color:"+randomColor+";}");
  21. });
  22.  
  23. })();