Instantly share code, notes, and snippets.

Embed
What would you like to do?
plugins.click_to_play でブロックしたプラグインを常に再生するメニューを作る
// ==UserScript==
// @name ClickToPlayMenu.uc.js
// @description plugins.click_to_play でブロックしたプラグインを常に再生するメニューを作る
// @namespace http://d.hatena.ne.jp/Griever/
// @author Griever
// @license MIT License
// @compatibility Firefox 14
// @charset UTF-8
// @include main
// @version 0.0.1
// ==/UserScript==
(function () {
var context = document.getElementById("contentAreaContextMenu");
var menuitem = document.createElement("menuitem");
menuitem.setAttribute("label", "このサイトのプラグインを常に再生する");
menuitem.setAttribute("class", "menuitem-iconic");
menuitem.setAttribute("image", "chrome://mozapps/skin/plugins/pluginGeneric-16.png");
context.appendChild(menuitem);
function onCommand(event) {
var target = gContextMenu.target;
if (!target) return;
var uri = Services.io.newURI(target.ownerDocument.location.href, null, null);
Services.perms.add(uri, "plugins", 1);
}
function onPopupShowing(event) {
var target = gContextMenu.target;
menuitem.hidden = !target || !(target instanceof HTMLEmbedElement);
}
menuitem.addEventListener("command", onCommand, false);
context.addEventListener("popupshowing", onPopupShowing, false);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment