Skip to content

Instantly share code, notes, and snippets.

@st98
Last active January 2, 2016 07:28
Show Gist options
  • Select an option

  • Save st98/8269747 to your computer and use it in GitHub Desktop.

Select an option

Save st98/8269747 to your computer and use it in GitHub Desktop.
mailtoスキームのリンクをクリックした際、メーラーを起動するかどうか聞くようにするユーティリティ。
// ==UserScript==
// @name mailto.js
// @namespace http://st98.github.io
// @description mailtoスキームのリンクをクリックした際、メーラーを起動するかどうか聞くようにするユーティリティ。
// @include *
// ==/UserScript==
;(function () {
[].forEach.call(document.getElementsByTagName('a'), function (element) {
var address = element.getAttribute('href');
address = address.match(/mailto:(.+)/);
if (address) {
element.addEventListener('click', function (e) {
if (!confirm('メーラーを起動しますか?\nmailto: ' + address[1])) {
e.preventDefault();
}
});
}
});
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment