Skip to content

Instantly share code, notes, and snippets.

@awef
Created July 31, 2010 23:11
Show Gist options
  • Save awef/502724 to your computer and use it in GitHub Desktop.
Save awef/502724 to your computer and use it in GitHub Desktop.
nicovideo-HighlightLockedTags.user.js
// ==UserScript==
// @description ニコニコ動画でロックされているタグを強調表示する
// @match http://www.nicovideo.jp/watch/*
// ==/UserScript==
"use strict";
var script = document.createElement("script");
script.innerHTML = '\
(function () {\
"use strict";\
\
var update = function () {\
var videoID = WatchJsApi.video.getVideoID();\
\
if (videoID) {\
var xhr = new XMLHttpRequest();\
xhr.onload = function () {\
var data = JSON.parse(this.responseText);\
\
var index = {};\
Array.prototype.forEach.call(\
document.querySelectorAll(".videoHeaderTag > a"),\
function (a) {\
index[a.textContent] = a;\
}\
);\
\
data.tags.forEach(function (tag) {\
if (tag.owner_lock === "1" && index[tag.tag]) {\
index[tag.tag].style.color = "hsl(120, 100%, 20%)";\
}\
});\
};\
xhr.open("GET",\
"/tag_edit/" + videoID + "/?res_type=json&cmd=tags&_=" + Date.now());\
xhr.send();\
}\
};\
\
WatchJsApi.video.onVideoChanged(update);\
update();\
})();\
';
document.head.appendChild(script);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment