Youtube-Geofind button for google maps

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);
})();