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


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);
})();
カテゴリー: Greasemonkey, JavaScript   パーマリンク

コメントをどうぞ

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

*

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>