Last active
December 20, 2015 14:29
-
-
Save hirogasa/6146989 to your computer and use it in GitHub Desktop.
ニコニコ動画の再生中ページのFaviconを変更するUserScript
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 NicovideoPlayingFavicon | |
// @namespace https://twitter.com/hirogasa/ | |
// @match http://www.nicovideo.jp/watch/* | |
// @description ニコニコ動画の再生中ページのFaviconを変更します。 | |
// @version 1.0 | |
// ==/UserScript== | |
(function(){ | |
var isPlaying = false; | |
var player = document.getElementById("flvplayer"); | |
var timer = setInterval(function(){checkStatus();}, 1000); | |
function checkStatus(){ | |
if(player.ext_getStatus() == "playing"){ | |
if(!isPlaying){ | |
changeFavicon("http://i.imgur.com/JYOD7ss.png"); | |
isPlaying = true; | |
} | |
}else if(isPlaying){ | |
changeFavicon("http://res.nimg.jp/img/favicon.ico"); | |
isPlaying = false; | |
} | |
} | |
function changeFavicon(url){ | |
var l = document.getElementsByTagName("link"); | |
for(var i = 0; i < l.length; i++) { | |
if(l[i].getAttribute("rel") == "shortcut icon"){ | |
l[i].parentNode.removeChild(l[i]); | |
break; | |
} | |
} | |
var m = document.createElement("link"); | |
m.rel = "shortcut icon"; | |
m.href = url; | |
document.getElementsByTagName("head")[0].appendChild(m); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
GINZAバージョン以降は下記のご利用をおすすめします。
https://gist.github.com/vzvu3k6k/6162695