Skip to content

Instantly share code, notes, and snippets.

@Griever
Created July 18, 2012 07:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Griever/3134922 to your computer and use it in GitHub Desktop.
Save Griever/3134922 to your computer and use it in GitHub Desktop.
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