Skip to content

Instantly share code, notes, and snippets.

@wardboumans
Created August 18, 2025 13:20
Show Gist options
  • Save wardboumans/d7254a1c4f4a81f871c3ad07ac158f85 to your computer and use it in GitHub Desktop.
Save wardboumans/d7254a1c4f4a81f871c3ad07ac158f85 to your computer and use it in GitHub Desktop.
Add a button to Google search pages to instantly search the same query on Yandex/Bing
// ==UserScript==
// @name Google to Yandex Search
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Add a button to Google search pages to instantly search the same query on Yandex
// @author Ward Boumans
// @match https://www.google.com/search*
// @match https://google.com/search*
// @match https://www.google.nl/search*
// @match https://google.nl/search*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Function to get the current search query from Google
function getCurrentSearchQuery() {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get('q') || '';
}
// Function to create and add the Yandex button
function addYandexButton() {
// Check if button already exists
if (document.getElementById('yandex-search-btn')) {
return;
}
const query = getCurrentSearchQuery();
if (!query) {
return;
}
// Create the Yandex button
const yandexButton = document.createElement('button');
yandexButton.id = 'yandex-search-btn';
yandexButton.innerHTML = 'Yandex';
yandexButton.style.cssText = `
position: fixed;
bottom: 20px;
right: 20px;
z-index: 9999;
background: white;
color: #333;
border: 1px solid #ddd;
padding: 8px 16px;
border-radius: 25px;
font-size: 14px;
font-weight: 500;
cursor: pointer;
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
transition: box-shadow 0.3s, transform 0.2s;
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
white-space: nowrap;
`;
// Add hover effect for Yandex
yandexButton.addEventListener('mouseenter', function() {
this.style.boxShadow = '0 4px 12px rgba(0,0,0,0.25)';
this.style.transform = 'translateY(-1px)';
});
yandexButton.addEventListener('mouseleave', function() {
this.style.boxShadow = '0 2px 8px rgba(0,0,0,0.15)';
this.style.transform = 'translateY(0)';
});
// Add click event to search on Yandex
yandexButton.addEventListener('click', function() {
const yandexUrl = `https://yandex.com/search/?text=${encodeURIComponent(query)}`;
window.open(yandexUrl, '_blank');
});
// Create the Bing button
const bingButton = document.createElement('button');
bingButton.id = 'bing-search-btn';
bingButton.innerHTML = 'Bing';
bingButton.style.cssText = `
position: fixed;
bottom: 75px;
right: 20px;
z-index: 9999;
background: white;
color: #333;
border: 1px solid #ddd;
padding: 8px 16px;
border-radius: 25px;
font-size: 14px;
font-weight: 500;
cursor: pointer;
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
transition: box-shadow 0.3s, transform 0.2s;
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
white-space: nowrap;
`;
// Add hover effect for Bing
bingButton.addEventListener('mouseenter', function() {
this.style.boxShadow = '0 4px 12px rgba(0,0,0,0.25)';
this.style.transform = 'translateY(-1px)';
});
bingButton.addEventListener('mouseleave', function() {
this.style.boxShadow = '0 2px 8px rgba(0,0,0,0.15)';
this.style.transform = 'translateY(0)';
});
// Add click event to search on Bing
bingButton.addEventListener('click', function() {
const bingUrl = `https://www.bing.com/search?q=${encodeURIComponent(query)}`;
window.open(bingUrl, '_blank');
});
// Add buttons to the page
document.body.appendChild(yandexButton);
document.body.appendChild(bingButton);
}
// Wait for page to load and add button
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', addYandexButton);
} else {
addYandexButton();
}
// Also add button when URL changes (for single-page app behavior)
let lastUrl = location.href;
new MutationObserver(() => {
const url = location.href;
if (url !== lastUrl) {
lastUrl = url;
setTimeout(addYandexButton, 500); // Small delay to ensure page is updated
}
}).observe(document, { subtree: true, childList: true });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment