dark-one-fix

Adding background color for sites that miss that attribute (see screenshots)

  1. // ==UserScript==
  2. // @name dark-one-fix
  3. // @namespace dark-one-fix
  4. // @description Adding background color for sites that miss that attribute (see screenshots)
  5. // @include http://*
  6. // @include https://*
  7. // @version 0.1.0
  8. // @author Sergey Ushakov <sergushakov.public@gmail.com>
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. /* globals window, document, Array */
  13.  
  14. (function() {
  15. 'use strict';
  16. var bgColor = document.body.style.backgroundColor || "",
  17. color = document.body.style.color || "",
  18. inputs = ["input", "textarea"],
  19. colors = {
  20. bgColor: "#fff",
  21. color: "#000"
  22. },
  23. mozDefColors = {
  24. bgColor: "rgb(32, 31, 31)",
  25. color: "rgb(212, 210, 207)"
  26. }
  27. ;
  28. if (bgColor.length === 0) {
  29. document.body.style.backgroundColor = colors.bgColor;
  30. }
  31. if (color.length === 0) {
  32. document.body.style.color = colors.color;
  33. }
  34.  
  35. inputs.forEach(function(selector) {
  36. Array.prototype.forEach.call(document.querySelectorAll(selector), function(x){
  37. var style = window.getComputedStyle(x, null);
  38. if (style.getPropertyValue("background-color") === mozDefColors.bgColor) {
  39. x.style.backgroundColor = colors.bgColor;
  40. }
  41. if (style.getPropertyValue("color") === mozDefColors.color) {
  42. x.style.color = colors.color;
  43. }
  44. });
  45. });
  46. })();