Skip to content

Instantly share code, notes, and snippets.

@tosunkaya
Forked from Daan-Grashoff/README.md
Created September 1, 2024 12:24
Show Gist options
  • Save tosunkaya/3eb76af032ebccdd1f0043f479bb93cf to your computer and use it in GitHub Desktop.
Save tosunkaya/3eb76af032ebccdd1f0043f479bb93cf to your computer and use it in GitHub Desktop.
Bring back the google maps button when searching on google
// ==UserScript==
// @name Google maps addon
// @namespace http://tampermonkey.net/
// @version 2024-03-21
// @description Bring google maps button back
// @author You
// @match https://www.google.com/*
// @icon https://www.google.com/
// @grant none
// ==/UserScript==
(function() {
'use strict';
function addMapsButton() {
// Find the list container of existing tabs
const tabsContainer = document.querySelector('.crJ18e');
// If tabs exist, proceed
if (tabsContainer) {
// Create the Maps button elements (updated)
const mapsListItem = document.createElement('div');
mapsListItem.jsname = 'VIftV';
// mapsListItem.classList.add('Ap1Qsc');
mapsListItem.setAttribute('role', 'listitem');
// Replace this entire section with the provided <a> element
const mapsButton = document.createElement('a');
mapsButton.jsname = "ONH4Gc";
mapsButton.classList.add("LatpMc");
mapsButton.classList.add("nPDzT");
mapsButton.classList.add("T3FoJb");
mapsButton.dataset.navigation = "server"; // Update the attribute name
mapsButton.dataset.hveid = "CAEQCA";
mapsButton.href = "//maps.google.com/maps?q=sligro&source=lmns&entry=mt&bih=999&biw=1758&prmd=isnvbz&hl=en";
mapsButton.ping = "/url?sa=t&source=web&rct=j&url=//maps.google.com/maps?q%3Dsligro%26source%3Dlmns%26entry%3Dmt%26bih%3D999%26biw%3D1758%26prmd%3Disnvbz%26hl%3Den&ved=2ahUKEwjluuaFof6EAxXBv_0HHZlMCckQi6AMKAN6BAgBEAg&opi=89978449";
// mapsButton.textContent = "Maps"; // Set the inner text
const mapsButtonText = document.createElement('div');
mapsButtonText.jsname = "bVqjv";
mapsButtonText.classList.add("YmvwI");
mapsButtonText.textContent = "Maps";
mapsButton.appendChild(mapsButtonText);
// Append the mapsButton to the list item
mapsListItem.appendChild(mapsButton);
// Insert the Maps button at the beginning of the tabs container
tabsContainer.prepend(mapsListItem);
}
}
// Call the function to add the button
addMapsButton();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment