Created
February 5, 2013 15:58
-
-
Save anonymous/4715364 to your computer and use it in GitHub Desktop.
Chromeでのみテスト。
YYCのプロフリンクにつぶやき、日記リンク、クリック時ポイント消費警告追加。
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 YYC Prof workaround | |
// @namespace http://www.yyc.co.jp/ | |
// @description YYCのプロフリンクにつぶやき、日記リンク、クリック時ポイント消費警告追加 | |
// @include http://www.yyc.co.jp/* | |
// ==/UserScript== | |
var links = document.querySelectorAll('a'); | |
for (var i = 0, len = links.length;i < len; i++) { | |
//対象となるプロフィール要素を取得 | |
var link = links[i]; | |
//プロフィール要素のリンク先URLを格納 | |
var hr = links[i].href; | |
//目的外のリンク先だったらパス | |
if(!hr.match(/profile\/[0-9]/)){ | |
continue; | |
} | |
//プロフィールIDを収得 | |
var prof_id = hr.match(/profile\/([0-9]+)/); | |
//つぶやきリンク追加 | |
var e_tsubu = document.createElement('a'); | |
e_tsubu.id = "id_t_"+i; | |
e_tsubu.target = "_blank"; | |
e_tsubu.href = "http://www.yyc.co.jp/short_message/other?id="+prof_id[1]; | |
e_tsubu.innerHTML = "[T]"; | |
link.parentNode.appendChild(e_tsubu); | |
//日記リンク追加 | |
var e_diary = document.createElement('a'); | |
e_diary.id = "id_d_"+i; | |
e_diary.target = "_blank"; | |
e_diary.href = "http://www.yyc.co.jp/diary/member/?id="+prof_id[1]; | |
e_diary.innerHTML = "[D]"; | |
link.parentNode.appendChild(e_diary); | |
//プロフクリック時の警告メッセージ追加 | |
link.addEventListener('click', function(e){ | |
if(!window.confirm("10pt消費します")){ | |
e.preventDefault(); | |
} | |
}, false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment