Skip to content

Instantly share code, notes, and snippets.

@moyashi
Last active February 21, 2020 03:13
Show Gist options
  • Save moyashi/ba59caa1161d44712adffc534492e86b to your computer and use it in GitHub Desktop.
Save moyashi/ba59caa1161d44712adffc534492e86b to your computer and use it in GitHub Desktop.
Googleマップの共有機能は短縮URLしか共有できず不便なので、地点名、住所を追加するUserScript。(Tampermonkeyで動作確認)
// ==UserScript==
// @name SharePlaceInTheRightWay
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.google.com/maps/*
// @match https://maps.google.com/*
// @grant none
// @require https://code.jquery.com/jquery-3.4.1.slim.min.js
// ==/UserScript==
(function() {
'use strict';
var replaceShareText = function(){
if ($(".section-copy-link-input-container").length > 0) {
var url = $(".section-copy-link-input-container input").prop("value");
// もしurlがhttps://goo.glから始まっていたら
if (/^https:\/\/goo.gl\/maps\//.test(url)) {
var title = $(".section-share-summary-title").text();
var subtitle = $(".section-share-summary-subtitle").text();
$(".section-copy-link-input-container input").prop("value", "\"" + title + " " + subtitle + "\" " + url);
}
}
};
setInterval(replaceShareText, 1000);
})();
@moyashi
Copy link
Author

moyashi commented Feb 20, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment