My Firefox extension is not working. What's the structure of a Firefox extension (XPI file) that uses C++ XPCOM componen
By : Ádám Gólya
Date : March 29 2020, 07:55 AM
it should still fix some issue I guess that you are following an outdated tutorial, most tutorials haven't been updated to XPCOM changes in Gecko 2.0. But to your questions: code :
interfaces components/mycomponent.xpt
binary-component components/mycomponent.dll ABI=WINNT_x86-msvc
|
form.submit is not a function - How to create and POST a form with (pure) Javascript in a Firefox extension
By : Quy Nguyen
Date : March 29 2020, 07:55 AM
help you fix your problem When you create a new element "form", you are creating it in the scope of the browser, hence you are creating a xul element. You would have to do it the way you create the "body" element: code :
var form = document.createElementNS('http://www.w3.org/1999/xhtml', 'form');
|
Firefox add-on pageMod, catch ajax done in contentScriptFile
By : CK Yap
Date : March 29 2020, 07:55 AM
like below fixes the issue Put this not in a content script: Im not sure how you will identify the content window of the script. I dont know sdk so well. But see the area CONTENT_WINDOW_OF_CONTENT_SCRIPT code :
const { Ci, Cu, Cc, Cr } = require('chrome'); //const {interfaces: Ci, utils: Cu, classes: Cc, results: Cr } = Components;
Cu.import('resource://gre/modules/Services.jsm');
Cu.import('resource://gre/modules/devtools/Console.jsm');
var observers = {
'http-on-modify-request': {
observe: function (aSubject, aTopic, aData) {
console.info('http-on-modify-request: aSubject = ' + aSubject + ' | aTopic = ' + aTopic + ' | aData = ' + aData);
var httpChannel = aSubject.QueryInterface(Ci.nsIHttpChannel);
var requestUrl = httpChannel.URI.spec
var goodies = loadContextAndGoodies(aSubject, true);
if (goodies.contentWindow) {
if (goodies.contentWindow == CONTENT_WINDOW_OF_CONTENT_SCRIPT) {
//do something here
}
}
},
reg: function () {
Services.obs.addObserver(observers['http-on-modify-request'], 'http-on-modify-request', false);
},
unreg: function () {
Services.obs.removeObserver(observers['http-on-modify-request'], 'http-on-modify-request');
}
}
};
function loadContextAndGoodies(request, return_goodies) {
var loadContext = null;
if (request instanceof Ci.nsIRequest) {
try {
if (request.loadGroup && request.loadGroup.notificationCallbacks) {
loadContext = request.loadGroup.notificationCallbacks.getInterface(Ci.nsILoadContext);
}
} catch (ex) {
console.exception('request loadGroup with notificationCallbacks but oculd not get nsIloadContext', ex);
}
if (!loadContext) {
try {
if (request.notificationCallbacks) {
loadContext = request.notificationCallbacks.getInterface(Ci.nsILoadContext);
}
} catch (ex) {
console.exception('request has notificationCallbacks but could not get nsILoadContext', ex);
/* start - noit's backup try, it might be redundant (im not sure) as Wladamir Palant didn't have this way*/
try {
var interfaceRequestor = httpChannel.notificationCallbacks.QueryInterface(Ci.nsIInterfaceRequestor);
loadContext = interfaceRequestor.getInterface(Ci.nsILoadContext);
} catch (ex) {
console.exception('backup method failed:' ex);
}
/* end - my backup try, it might be redundant as Wladamir Palant didn't have this way*/
}
}
} else {
console.warn('request argument is not instance of nsIRequest')
}
if (return_goodies) {
if (!loadContext) {
return null;
}
var contentWindow = loadContext.associatedWindow;
var DOMWindow = contentWindow.top.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
var gBrowser = DOMWindow.gBrowser;
if (gBrowser) {
var tab = gBrowser._getTabForContentWindow(contentWindow.top);
var browser = tab.linkedBrowser;
} else {
var tab, browser = null;
}
var goodies = {
loadContext: loadContext,
DOMWindow: DOMWindow,
gBrowser: gBrowser,
contentWindow: contentWindow,
browser: browser,
tab: tab
};
return goodies;
} else {
return loadContext;
}
}
for (var o in observers) {
observers[o].reg();
}
for (var o in observers) {
observers[o].unreg();
}
|
How to use a contentScriptFile from an external URI in a Firefox addon
By : pgetsos
Date : March 29 2020, 07:55 AM
may help you . My latest update to a Firefox addon has been rejected because I've used a custom jquery-ui (generated by their site with just the widgets I wanted) and it fails their checksum check. , self.data.url("https://...")
|
Firefox add-on : passing value from context menu to contentScriptFile after selection
By : ยายโบว์วี่ ติดแรด
Date : March 29 2020, 07:55 AM
|