Greasy Fork 还支持 简体中文。

Change Background Color for Google

Adds a button to change the background color of Google search page on load and removes the carbon neutral since 2007 and everything related to it. Will apply to all google links may be broken on other pages other than google.com or other language versions of google.com

目前為 2023-07-18 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name Change Background Color for Google
// @namespace https://greasyfork.org/users/1129625
// @license MIT
// @version 1.3
// @description Adds a button to change the background color of Google search page on load and removes the carbon neutral since 2007 and everything related to it.      Will apply to all google links may be broken on other pages other than google.com or other language versions of google.com
// @match   https://www.google.com/*
// ==/UserScript==

(function() {
  'use strict';

  // Find the element to remove
  var elementToRemove = document.querySelector('div[data-sfsw="1200"]');

  // Check if the element exists
  if (elementToRemove) {
    // Remove the element from the DOM
    elementToRemove.parentNode.removeChild(elementToRemove);
  }

  // Create the button element
  var button = document.createElement('button');
  button.textContent = 'Change Color';
  button.style.position = 'relative';
  button.style.marginLeft = '10px';

  // Find the Store button
  var storeButton = document.querySelector('[aria-label="Google apps"]');

  // Insert the button next to the Store button
  storeButton.parentNode.insertBefore(button, storeButton.nextSibling);

  // Add click event listener to change the background color
  button.addEventListener('click', function() {
    var color = prompt(
      "Select a color:\n1. Blue\n2. Red\n3. Green\n4. Yellow\n5. Purple\n6. Orange\n7. Pink\n8. Teal\n9. Gray\n10. Brown\n11. Custom RGB"
    );

    if (color !== null) {
      switch (color) {
        case "1":
          document.body.style.backgroundColor = "blue";
          break;
        case "2":
          document.body.style.backgroundColor = "red";
          break;
        case "3":
          document.body.style.backgroundColor = "green";
          break;
        case "4":
          document.body.style.backgroundColor = "yellow";
          break;
        case "5":
          document.body.style.backgroundColor = "purple";
          break;
        case "6":
          document.body.style.backgroundColor = "orange";
          break;
        case "7":
          document.body.style.backgroundColor = "pink";
          break;
        case "8":
          document.body.style.backgroundColor = "teal";
          break;
        case "9":
          document.body.style.backgroundColor = "gray";
          break;
        case "10":
          document.body.style.backgroundColor = "brown";
          break;
        case "11":
          var rgbColor = prompt(
            "Enter a custom RGB value (e.g., 'rgb(255, 0, 0)'):"
          );
          if (rgbColor !== null) {
            document.body.style.backgroundColor = rgbColor;
          }
          break;
        default:
          alert("Invalid selection. Please choose a valid option.");
      }
    }
  });
})();