Add Background to Body

Adds a white background to the page if it doesn't have one specified. This can help if you have a transparency in your browser (e.g. Zen Browser)

目前为 2025-02-03 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Add Background to Body
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Adds a white background to the page if it doesn't have one specified. This can help if you have a transparency in your browser (e.g. Zen Browser)
  6. // @author Maniac
  7. // @match *://*/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. window.addEventListener('load', function() {
  16. const bodyStyle = window.getComputedStyle(document.body);
  17.  
  18. if (!bodyStyle.backgroundImage && !bodyStyle.background && bodyStyle.backgroundImage === 'none' || bodyStyle.backgroundColor === 'rgba(0, 0, 0, 0)') {
  19. document.body.style.backgroundColor = "#ffffff"; // Set background to white
  20. }
  21. });
  22. })();