Skip to content

Instantly share code, notes, and snippets.

@hyuki
Created May 8, 2018 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyuki/18cd0b5ceaf95b34059855c57c090ad4 to your computer and use it in GitHub Desktop.
Save hyuki/18cd0b5ceaf95b34059855c57c090ad4 to your computer and use it in GitHub Desktop.
edit.js - いまいるURLの数字部分を切り出して、それに対応しているファイルを編集するためのコマンドを作って表示するブックマークレット
/*
* https://math.hyuki.net/20180508235800/ のようなページにアクセスしているとき、
* "vi ~/Documents/doc/math.hyuki.net/txt/20180508235800.txt"というコマンド文字列を表示してくれる。
*/
function start() {
if (location.href.match(/math.hyuki.net\/(\d+)/)) {
prompt('Edit Me!', 'vi ~/Documents/doc/math.hyuki.net/txt/' + RegExp.$1 + '.txt');
} else {
alert("math.hyuki.net/YYYYMMDDhhmmss is not found.");
}
}
start();
@hyuki
Copy link
Author

hyuki commented May 8, 2018

Bookmarkletへの変換は以下のようなサイトを使うと手軽。
https://mrcoles.com/bookmarklet/

@hyuki
Copy link
Author

hyuki commented May 8, 2018

結城が作ったいくつかのBookmarklet
https://snap.textfile.org/javascript/

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