// ==UserScript==
// @name Custom Google Homepage
// @namespace https://gf.qytechs.cn/users/1129625
// @version 2.3
// @description Customize the Google homepage by adding buttons, a color changer feature, social media buttons, and daily facts.
// @match *://www.google.com/*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// Remove the Advertising, Business, and How Search works div
var adBusinessDiv = document.querySelector('div[data-sfe="true"]');
if (adBusinessDiv) {
adBusinessDiv.remove();
}
// Find the Google Apps button
var appsButton = document.querySelector('a.gb_d');
if (appsButton) {
// Create the color changer button
var changeColorButton = createColorChangerButton();
changeColorButton.style.marginRight = '10px';
changeColorButton.style.cursor = 'pointer';
// Replace the Google Apps button with the color changer button
appsButton.parentNode.replaceChild(changeColorButton, appsButton);
}
// Find the About button
var aboutButton = document.querySelector('a[href*="about.google"]');
if (aboutButton) {
// Replace the About button with the YouTube button
var youtubeButton = createButton('YouTube', 'https://www.youtube.com');
aboutButton.parentNode.replaceChild(youtubeButton, aboutButton);
}
// Find the Store button
var storeButton = document.querySelector('a[href*="store.google.com"]');
if (storeButton) {
// Replace the Store button with the Twitch button and color wheel
var twitchButton = createButtonWithColorWheel('Twitch', 'https://www.twitch.tv');
storeButton.parentNode.replaceChild(twitchButton, storeButton);
}
// Find the Images button
var imagesButton = document.querySelector('a[href*="google.com/imghp"]');
if (imagesButton) {
// Replace the Images button with the Discord button
var discordButton = createButton('Discord', 'https://www.discord.com');
imagesButton.parentNode.replaceChild(discordButton, imagesButton);
}
// Create the Reddit button
var redditButton = createButton('Reddit', 'https://www.reddit.com');
redditButton.style.marginRight = '10px';
redditButton.style.cursor = 'pointer';
// Create the Twitter button
var twitterButton = createButton('Twitter', 'https://www.twitter.com');
twitterButton.style.marginRight = '10px';
twitterButton.style.cursor = 'pointer';
// Create the Instagram button
var instagramButton = createButton('Instagram', 'https://www.instagram.com');
instagramButton.style.marginRight = '10px';
instagramButton.style.cursor = 'pointer';
// Create the Facebook button
var facebookButton = createButton('Facebook', 'https://www.facebook.com');
facebookButton.style.marginRight = '10px';
facebookButton.style.cursor = 'pointer';
// Create the Random Number button
var randomNumberButton = createRandomNumberButton();
randomNumberButton.style.marginRight = '10px';
randomNumberButton.style.cursor = 'pointer';
// Create the New Fact button
var newFactButton = createNewFactButton();
newFactButton.style.marginRight = '10px';
newFactButton.style.cursor = 'pointer';
// Find the color wheel container
var colorWheelContainer = document.querySelector('div[style="margin-right: 10px;"]');
if (colorWheelContainer) {
// Insert the Reddit button after the color wheel container
colorWheelContainer.parentNode.insertBefore(redditButton, colorWheelContainer.nextSibling);
// Insert the Twitter button after the Reddit button
redditButton.parentNode.insertBefore(twitterButton, redditButton.nextSibling);
// Insert the Instagram button after the Twitter button
twitterButton.parentNode.insertBefore(instagramButton, twitterButton.nextSibling);
// Insert the Facebook button after the Twitter button
twitterButton.parentNode.insertBefore(facebookButton, instagramButton.nextSibling);
// Insert the Random Number button after the Facebook button
facebookButton.parentNode.insertBefore(randomNumberButton, facebookButton.nextSibling);
// Insert the New Fact button after the Random Number button
randomNumberButton.parentNode.insertBefore(newFactButton, randomNumberButton.nextSibling);
}
// Function to create a button element
function createButton(text, url) {
var button = document.createElement('a');
button.textContent = text;
button.href = url;
button.style.marginRight = '10px';
button.style.cursor = 'pointer';
return button;
}
// Function to create a button element with a color wheel
function createButtonWithColorWheel(text, url) {
var buttonContainer = document.createElement('div');
buttonContainer.style.display = 'flex';
buttonContainer.style.alignItems = 'center';
var button = document.createElement('a');
button.textContent = text;
button.href = url;
button.style.marginRight = '10px';
button.style.cursor = 'pointer';
var colorWheelContainer = document.createElement('div');
colorWheelContainer.style.marginRight = '10px';
var colorWheel = document.createElement('input');
colorWheel.type = 'color';
colorWheel.addEventListener('input', function(event) {
document.body.style.backgroundColor = event.target.value;
});
colorWheelContainer.appendChild(colorWheel);
buttonContainer.appendChild(button);
buttonContainer.appendChild(colorWheelContainer);
return buttonContainer;
}
// Function to create the Color Changer button
function createColorChangerButton() {
var button = document.createElement('button');
button.textContent = 'Change Color';
button.style.marginRight = '10px';
button.style.cursor = 'pointer';
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. SkyBlue\n12. Cyan\n13. Magenta\n14. Lime\n15. Indigo\n16. Olive\n17. Silver\n18. Maroon\n19. Navy\n20. Custom Color"
);
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":
document.body.style.backgroundColor = "skyblue";
break;
case "12":
document.body.style.backgroundColor = "cyan";
break;
case "13":
document.body.style.backgroundColor = "magenta";
break;
case "14":
document.body.style.backgroundColor = "lime";
break;
case "15":
document.body.style.backgroundColor = "indigo";
break;
case "16":
document.body.style.backgroundColor = "olive";
break;
case "17":
document.body.style.backgroundColor = "silver";
break;
case "18":
document.body.style.backgroundColor = "maroon";
break;
case "19":
document.body.style.backgroundColor = "navy";
break;
case "20":
showCustomColor();
break;
default:
alert("Invalid selection. Please choose a valid option.");
}
}
});
return button;
}
// Function to show the custom color prompt
function showCustomColor() {
var customColor = prompt(
"Enter a custom color (HEX or RGB):"
);
if (customColor !== null) {
document.body.style.backgroundColor = customColor;
}
}
// Function to create the Random Number button
function createRandomNumberButton() {
var button = document.createElement('button');
button.textContent = 'Random Number';
button.style.marginRight = '10px';
button.style.cursor = 'pointer';
button.addEventListener('click', function() {
var randomNumber = Math.floor(Math.random() * 101);
alert('Random Number: ' + randomNumber);
});
return button;
}
// Function to create the New Fact button
function createNewFactButton() {
var button = document.createElement('button');
button.textContent = 'New Fact';
button.style.marginRight = '10px';
button.style.cursor = 'pointer';
button.addEventListener('click', function() {
var currentDay = new Date().getDate();
var fact = getFactOfTheDay(currentDay);
alert('Fact of the Day: ' + fact);
});
return button;
}
// Function to get the fact of the day based on the current day
function getFactOfTheDay(day) {
var facts = [
'The Earth is the third planet from the Sun.',
'Water covers about 71% of the Earth\'s surface.',
'The Great Wall of China is visible from space.',
'The human body is made up of approximately 60% water.',
'The speed of light is approximately 299,792,458 meters per second.',
'The largest ocean on Earth is the Pacific Ocean.',
'The Eiffel Tower is located in Paris, France.',
'The Statue of Liberty was a gift from France to the United States.',
'The Mona Lisa was painted by Leonardo da Vinci.',
'The planet Mars is also known as the "Red Planet".',
'Mount Everest is the highest mountain in the world.',
'The Amazon rainforest is the largest tropical rainforest on Earth.',
'The Nile River is the longest river in the world.',
'The Taj Mahal is located in Agra, India.',
'The Great Barrier Reef is the largest coral reef system in the world.',
'The Colosseum is located in Rome, Italy.',
'The Sahara Desert is the largest hot desert in the world.',
'The Sydney Opera House is located in Sydney, Australia.',
'The polar bear is the largest species of bear.',
'The moon is approximately 384,400 kilometers away from Earth.',
'The Statue of Liberty full name is "Liberty Enlightening the World".',
'The Leaning Tower of Pisa is located in Pisa, Italy.',
'The pyramids of Giza were built as tombs for the pharaohs.',
'The Arctic is home to the North Pole.',
'The Mediterranean Sea is connected to the Atlantic Ocean.',
'The Galapagos Islands are located in the Pacific Ocean.',
'The Golden Gate Bridge is located in San Francisco, California.',
'The kangaroo is a marsupial native to Australia.',
'The Vatican City is the smallest independent state in the world.',
'The Red Sea is known for its diverse marine life.',
'The Hollywood sign is located in Los Angeles, California.'
// Add more facts here
];
// Get the fact corresponding to the current day
var factIndex = (day - 1) % facts.length;
return facts[factIndex];
}
})();