Quick Inverse Images color by Alt+C

Alt+C to inverse images on all page, use for win10 inverse color mode (as a dark mode, while images shows right colors)

  1. // ==UserScript==
  2. // @name Quick Inverse Images color by Alt+C
  3. // @namespace https://snomiao.com
  4. // @version 0.1
  5. // @description Alt+C to inverse images on all page, use for win10 inverse color mode (as a dark mode, while images shows right colors)
  6. // @author snomiao
  7. // @match http*://*/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. 'use strict';
  13.  
  14. let head, style;
  15. head = document.getElementsByTagName('head')[0];
  16. if (!head) {
  17. return;
  18. }
  19. style = document.createElement('style');
  20. style.type = 'text/css';
  21. style.innerHTML = '';
  22. head.appendChild(style);
  23.  
  24. const toggle = () =>
  25. (style.innerHTML = style.innerHTML ? '' : `img{filter: invert(100%);}`);
  26. window.addEventListener('keydown', (e) => {
  27. if (e.altKey && !e.shiftKey && !e.ctrlKey && e.code == 'KeyC') {
  28. toggle();
  29. }
  30. });
  31. })();