Skip to content

Instantly share code, notes, and snippets.

@kkotaro0111
Last active August 29, 2015 13:57
Show Gist options
  • Save kkotaro0111/9384194 to your computer and use it in GitHub Desktop.
Save kkotaro0111/9384194 to your computer and use it in GitHub Desktop.
Youtubeの動画管理ページから、各動画の経過日数と1日あたりの再生数を表示する。consoleにコピペして、addinfo()を呼ぼう。
(function(){
//load jQuery
var loadjq = document.createElement("script");
loadjq.type = "text/javascript";
loadjq.src = "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js";
document.body.appendChild(loadjq);
})();
function addinfo(){
var vi = $(".vm-video-item");
var today = new Date();
vi.each(function(index, elem){
var ld = $(elem).find(".vm-video-info").find(".localized-date");
var ldstmp = ld.data("timestamp");
var lddate = new Date(ldstmp*1000);
var title = $(elem).find(".vm-video-title-content").text();
var diftime = Math.round((today.getTime() - ldstmp*1000) / 1000 / 60 / 60 / 24);
var playedNum = $(elem).find(".video-view-count").find(".vm-video-metric-value");
var playedNumValue = playedNum.text().replace(/,/,"") << 0;
ld.after(" / " + diftime + "日前");
playedNum.after(" / " + Math.ceil(playedNumValue / diftime));
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment