Window.location.Replace In Firefox Addon elimina el cromo completo!
-
23-09-2019 - |
Pregunta
Estoy usando el nsIWebProgressListener
interfaz Para averiguar si se ha cambiado una URL. Si es así, me gustaría reescribir el enlace. Aquí hay un fragmento (código tomado desde la parte inferior de la página desde el enlace de arriba)
var myExt_urlBarListener = {
QueryInterface: function(aIID)
{
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
aIID.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
},
onLocationChange: function(aProgress, aRequest, aURI)
{
myExtension.processNewURL(aURI);
},
onStateChange: function(a, b, c, d) {},
onProgressChange: function(a, b, c, d, e, f) {},
onStatusChange: function(a, b, c, d) {},
onSecurityChange: function(a, b, c) {}
};
var myExtension = {
oldURL: null,
init: function() {
// Listen for webpage loads
gBrowser.addProgressListener(myExt_urlBarListener,
Components.interfaces.nsIWebProgress.NOTIFY_LOCATION);
},
uninit: function() {
gBrowser.removeProgressListener(myExt_urlBarListener);
},
processNewURL: function(aURI) {
if (aURI.spec == this.oldURL)
return;
// now we know the url is new...
start_work(aURI.spec);
this.oldURL = aURI.spec;
}
};
window.addEventListener("load", function() {myExtension.init()}, false);
window.addEventListener("unload", function() {myExtension.uninit()}, false);
Y una función para manejar el cambio:
function start_work(url)
{
result = check(url);
if (result) {
setCookie('bws', 'true', 1, '/');
window.location = result; // or window.location.replace, doesn't matter
}
}
¡Esto es lo que pasa!texto alt http://grab.by/20ep¡Como puede ver todo el navegador/barra de dirección/cromo desapareció!
¿Alguna ayuda sobre esto?
No hay solución correcta
Otros consejos
Simple: Agregar window.content.location
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow