リンクを解除するユーザスクリプト

HTML のリンクに設定されたテキストの "ある一部だけをマウスで選択してコピーしたい" ことが、一年に一度くらいあります。
それを実現するユーザスクリプトを書きました。任意のリンクを解除するだけですが。

RemoveAnchor.user.js

使い方

リンクのテキストにフォーカスがある状態で、d キーを押します。
リンクのテキストにフォーカスを当てるには、リンクのテキストを右クリックして Esc キーを押すか、リンクのテキストをドラッグして放します。

ソースコード

// ==UserScript==
// @name           RemoveAnchor
// @namespace      http://blog.kaihatsubu.com/
// @description    remove focused anchor element's href attribute
// ==/UserScript==
(function() {
document.addEventListener("keypress", function(event) {
if ((event.which == 100) && document.activeElement.href) {
document.activeElement.removeAttribute("href");
}
}, false);
})();