Created
October 2, 2011 03:58
-
-
Save nobodyplace/1257023 to your computer and use it in GitHub Desktop.
ニコニコ動画のcanonicalを置き換えるGreasemonkey
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 Nico Canonical | |
// @version 0.0.1 | |
// @namespace https://gist.github.com/1257023 | |
// @description ニコニコ動画のcanonicalを置き換えるGreasemonkey | |
// @include http://www.nicovideo.jp/watch/* | |
// @updated 2011/10/02 12:56:00 | |
// ==/UserScript== | |
// 0.0.1 - 2011/10/02 リリース | |
(function(doc){ | |
'use strict'; | |
var w = unsafeWindow; //ページ内要素にアクセスするためunsafeWindowを使用する | |
var id = w.Video['id']; //動画ID | |
var links = doc.getElementsByTagName('head')[0].getElementsByTagName('link'); | |
for (var i=0; i<links.length; i++) { | |
if (links[i].getAttribute('rel').toLowerCase() == 'canonical') { | |
links[i].href = '/watch/' + id; | |
break; | |
} | |
} | |
})(document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment