私は既に Youtube というグリースモンキー スクリプトを使用しています: http://userscripts.org/scripts/review/47198
このスクリプトは、既にアクセスしたリンクを強調表示することを目的としています。重要な要素は、a:visited を無効にする URL パラメータを削除することです。
i.e.: http://www.youtube.com/watch?v=aKWPht3fU-o !=
http://www.youtube.com/watch?v=aKWPht3fU-o&featured=fvw
重要な部分は次のとおりです。
var cleanlink, dirtylink, i, x, aXpath;
aXpath = new Array(7);
aXpath[0] = '//a[contains(@href, "feature=related")]';
aXpath[1] = '//a[contains(@href, "feature=relmfu")]';
aXpath[2] = '//a[contains(@href, "feature=g-")]';
aXpath[3] = '//a[contains(@href, "feature=b-")]'; // &feature=b- all browse
aXpath[4] = '//a[contains(@href, "/user/")]';
aXpath[5] = '//a[contains(@href, "/videos")]'; // search
aXpath[6] = '//a[contains(@href, "&list")]'; // playlists
for(x in aXpath) {
dirtylink = document.evaluate(aXpath[x], document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (i = 0; i < dirtylink.snapshotLength; i++) {
cleanlink = dirtylink.snapshotItem(i);
switch (x){
case 6:
cleanlink.href = cleanlink.href.replace(/\&feature(.*)/,"").replace(/\&index(.*)/,"");
break;
case 4:
case 5:
cleanlink.href = cleanlink.href.replace(/\?(.*)/,"");
break;
default :
cleanlink.href = cleanlink.href.replace(/\&(.*)/,"");
}
}
}
問題は、このコードが標準の HTML youtube ページのリンクのみをチェックすることです。AJAX で追加されたリンク (主に YouTube チャンネル) は正規化されません。
AJAX が挿入されたリンクを使用しても、このユーザー スクリプトを実行する方法はありますか?