Skip to content

Instantly share code, notes, and snippets.

@hirogasa
Last active December 20, 2015 14:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hirogasa/6146989 to your computer and use it in GitHub Desktop.
Save hirogasa/6146989 to your computer and use it in GitHub Desktop.
ニコニコ動画の再生中ページのFaviconを変更するUserScript
// ==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);
}
})();
@hirogasa
Copy link
Author

GINZAバージョン以降は下記のご利用をおすすめします。
https://gist.github.com/vzvu3k6k/6162695

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment