您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Fügt den Maps-Tab zur Google-Suche hinzu, wenn er in der EU nicht angezeigt wird
- // ==UserScript==
- // @name Google Maps Tab für EU Benutzer
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description Fügt den Maps-Tab zur Google-Suche hinzu, wenn er in der EU nicht angezeigt wird
- // @author Mindworker
- // @match https://www.google.com/search*
- // @match https://www.google.de/search*
- // @match https://www.google.at/search*
- // @match https://www.google.fr/search*
- // @match https://www.google.it/search*
- // @match https://www.google.es/search*
- // @match https://www.google.nl/search*
- // @match https://www.google.be/search*
- // @match https://www.google.pl/search*
- // @grant none
- // @license MIT
- // ==/UserScript==
- (function() {
- 'use strict';
- // Funktion zum Überprüfen, ob der Maps-Tab existiert
- function mapsTabExists() {
- const tabElements = document.querySelectorAll('div[role="navigation"] a');
- for (let tab of tabElements) {
- if (tab.textContent.includes('Maps') || tab.textContent.includes('Karten')) {
- return true;
- }
- }
- return false;
- }
- // Funktion zum Erstellen und Einfügen des Maps-Tabs
- function addMapsTab() {
- // Warte, bis die Tab-Navigation geladen ist
- const checkForNavigation = setInterval(function() {
- const tabNavigation = document.querySelector('div[role="navigation"]');
- if (tabNavigation && !mapsTabExists()) {
- clearInterval(checkForNavigation);
- // Erstelle den neuen Tab
- const tabsContainer = tabNavigation.querySelector('div');
- if (tabsContainer) {
- // Bestehende Tabs finden
- const existingTabs = tabsContainer.querySelectorAll('a');
- if (existingTabs.length > 0) {
- // Klone einen bestehenden Tab als Vorlage
- const templateTab = existingTabs[0].cloneNode(true);
- // Aktuellen Suchbegriff ermitteln
- const searchQuery = new URLSearchParams(window.location.search).get('q') || '';
- // Tab anpassen
- templateTab.href = `https://www.google.com/maps/search/${encodeURIComponent(searchQuery)}`;
- // Sprachabhängige Bezeichnung
- const language = document.documentElement.lang || navigator.language || 'en';
- const tabText = language.startsWith('de') ? 'Karten' : 'Maps';
- // Text und Aussehen anpassen
- if (templateTab.querySelector('span')) {
- templateTab.querySelector('span').textContent = tabText;
- } else {
- templateTab.textContent = tabText;
- }
- // Tab an geeigneter Stelle einfügen (nach "Bilder" bzw. "Images")
- let insertAfter = existingTabs[0];
- for (let tab of existingTabs) {
- const tabText = tab.textContent.toLowerCase();
- if (tabText.includes('bilder') || tabText.includes('images')) {
- insertAfter = tab;
- break;
- }
- }
- // Tab einfügen
- insertAfter.parentNode.insertBefore(templateTab, insertAfter.nextSibling);
- console.log('Maps-Tab wurde hinzugefügt');
- }
- }
- }
- }, 500);
- }
- // Initialisierung
- window.addEventListener('load', function() {
- setTimeout(addMapsTab, 1000);
- });
- // Auch bei AJAX-Navigation (wenn Google Ergebnisse dynamisch nachlädt)
- const observer = new MutationObserver(function(mutations) {
- for (let mutation of mutations) {
- if (mutation.type === 'childList' && !mapsTabExists()) {
- addMapsTab();
- break;
- }
- }
- });
- // Beobachtung des DOM starten
- setTimeout(function() {
- const searchResults = document.getElementById('search');
- if (searchResults) {
- observer.observe(searchResults, { childList: true, subtree: true });
- }
- }, 1500);
- })();