私はmozillaによって提供されたaddon-sdkで少しのFirefoxアドオンを開発しています。アドオンは1つの特定のWebサイトでのみ動作し、このWebサイトからjsファイルをブロックする必要があります。私はそのような要求をブロックする方法について何時間も探しています。JSをFirefox Addonでブロックする
うまくいけば、誰かが答え
私はmozillaによって提供されたaddon-sdkで少しのFirefoxアドオンを開発しています。アドオンは1つの特定のWebサイトでのみ動作し、このWebサイトからjsファイルをブロックする必要があります。私はそのような要求をブロックする方法について何時間も探しています。JSをFirefox Addonでブロックする
うまくいけば、誰かが答え
うんを知っている、あなたは、ほとんどが手作業でこれを実行する必要があると思います。 SDKはここではあまり役に立ちませんが、いくらか可能です。
これはあなたがする必要がある行に沿っています。これはテストされておらず、すぐには動作しませんが、どのコンポーネントが関与しているか、さらに多くのリソースを見つける場所を知ることができます。
const { Cc, Ci, Cm, components } = require("chrome");
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
const CategoryManager = Cc["@mozilla.org/categorymanager;1"]
.getService(Ci.nsICategoryManager);
function PolicyComponent() { }
PolicyComponent.prototype = {
desc: "My nsIContentPolicy XPCOM Component",
classID: components.ID("{3ffd2f60-3784-11e1-b86c-0800200c9a66}"),
contractID: "@abc.def.com/policycomp;1",
QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPolicy]),
shouldLoad: function(contentType, contentLocation, requestOrigin, aContext, mimeTypeGuess, extra) {
if (contentLocation.spec != BLOCKED_JS) { return return Ci.nsIContentPolicy.ACCEPT; }
else { return Ci.nsIContentPolicy.REJECT_REQUEST; }
},
shouldProcess: function() {
return CI.nsIContentPolicy.ACCEPT;
}
}
var pc = new PolicyComponent()
// Register the Interface
Cm.QueryInterface(Ci.nsIComponentRegistrar).registerFactory(pc.uuid, pc.desc, pc.contractID, pc);
// Add the content policy
CategoryManager.addCategoryEntry("content-policy",pc.className,pc.contractID, true, true); // not sure you should replace (last true statement)
多くのため、この記事を参照してください: What is missing in my nsIContentPolicy Firefox/IceWeasel extension XPCOMponent implementation for the shouldLoad to be called?
はまた、これらのドキュメントを見てみましょう:https://developer.mozilla.org/en/XUL_School/Intercepting_Page_Loads#Content_Policy要求をブロック
は(httpsを使用すると、通常は[nsIContentPolicy]実装するXPCOMコンポーネントを作成することによって行うだろう何かであります://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIContentPolicy)。しかし、それは非常に重要ではないし、SDKはあなたにそれのためのツールを提供していません。 –