Youtube-Geofind button for google maps

add a button to open Youtube-Geofind at the actual google maps coordinates

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Youtube-Geofind button for google maps
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  add a button to open Youtube-Geofind at the actual google maps coordinates
// @author       Guile93 (twitch.tv/Guile)
// @license MIT 
// @match        https://www.google.com/maps/*
// @match        https://www.google.fr/maps/*
// @icon         https://mattw.io/youtube-geofind/img/icon.png
// @grant        none
// ==/UserScript==
(function() {
    var css = `
      .btn{
            background-color: #CC0000;
            border: 1px solid brown;
            height:30px;
            margin-right:5px;
            border-radius: 6px;
            box-shadow: rgba(27, 31, 35, .1) 0 1px 0;
            box-sizing: border-box;
            color: #fff;
            cursor: pointer;
            display: inline-block;
            font-family: -apple-system,system-ui,"Segoe UI\",Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji";
            font-size: 12px;
            font-weight: 600;
            line-height: 20px;
            padding: 0px 16px;
            position: relative;
            float: right;
            text-align: center;
            touch-action: manipulation;
            vertical-align: middle;
          }
          .btn:hover {
            background-color: #FF0000;
          }
          `
    var head = document.getElementsByTagName('head')[0];
    var s = document.createElement('style');
    s.setAttribute('type', 'text/css');
    s.appendChild(document.createTextNode(css));
    head.appendChild(s);
    let btn = document.createElement("button");
    btn.innerHTML = "YG";
    btn.name="goGeofind";
    btn.className="btn";
    btn.addEventListener("click", function () {
        let regexp = /(-?\d+\.\d+),(-?\d+\.\d+)/gi;
        let txt=window.location.href;
        let coords = txt.match(regexp)
        if(coords){
            window.open('https://mattw.io/youtube-geofind/location?location='+coords+'&radius=5&doSearch=true');
        }else{alert('erreur de coordonnées veuillez vous déplacer ou rafraichir');}
    });
    var target=document.getElementById("downgrade");
    target.appendChild(btn);
})();