Created
October 16, 2020 13:32
-
-
Save kemsakurai/6105d89adf2292fa9632c7887a148946 to your computer and use it in GitHub Desktop.
ブラウザSafari で使っているTampermonkey スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name My BookMarklet | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description BookMarklet | |
// @author mutter.monotalk | |
// @match *://*/* | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function openMarkdownLinkPrompt() { | |
window.prompt("Markdown link","["+document.title+"]("+location.href+")"); | |
} | |
function openGoogleDriveImageDirectLinkPrompt() { | |
if (window.location.href.indexOf("https://drive.google.com/file/d/") != -1) { | |
var id = location.href.split('/')[5]; | |
window.prompt("Google Drive image direct link", "https://drive.google.com/uc?export=view&id=" + id); | |
} | |
} | |
function shareTwitter() { | |
var w = 550; | |
var h = 420; | |
window.open("https://twitter.com/intent/tweet?status="+encodeURIComponent(document.title)+" "+encodeURIComponent(location.href),"_blank","width="+w+",height="+h+",left="+(screen.width-w)/2+",top="+(screen.height-h)/2+",scrollbars=yes,resizable=yes,toolbar=no,location=yes"); | |
} | |
function openChatworkSharePrompt() { | |
window.prompt('ChatWork link','[info][title]'+document.title.replace(/([\[\]])/g,'\\$1')+'[/title]'+location.href+'\n'+window.getSelection()+'[/info]'); | |
} | |
function setUpShortCuts(e) { | |
if (e.altKey) { | |
switch (e.keyCode) { | |
// 1 | |
case 49: | |
openMarkdownLinkPrompt(); | |
break; | |
// 2 | |
case 50: | |
openGoogleDriveImageDirectLinkPrompt(); | |
break; | |
// 3 | |
case 51: | |
shareTwitter(); | |
break; | |
// 4 | |
case 52: | |
openChatworkSharePrompt(); | |
break; | |
default: | |
break; | |
} | |
} | |
} | |
document.addEventListener('keyup', setUpShortCuts, false); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment