Last active
August 29, 2015 14:11
-
-
Save linusyu/3faebb589642afcf9021 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location.href === "chrome://browser/content/browser.xul" && (function(){ | |
"use strict"; | |
if(typeof fireTrimURL !== "undefined") return; | |
var fireTrimURL = { | |
init: function() { | |
gBrowser.addProgressListener(this); | |
}, | |
uninit: function() { | |
gBrowser.removeProgressListener(this); | |
}, | |
urlbar: document.querySelector("#urlbar"), | |
processNewURL: function(aURI) { | |
if(/\s+/g.test(this.urlbar.value)){ | |
var newURL = this.urlbar.value = this.urlbar.value.replace(/\s+/g,""); | |
var h = /(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|&|-)+)/g; | |
gBrowser.contentDocument.location.href = h.test(newURL) ? | |
newURL : "http://"+newURL; | |
} | |
}, | |
QueryInterface: XPCOMUtils.generateQI(["nsIWebProgressListener", | |
"nsISupportsWeakReference"]), | |
onLocationChange: function(aProgress, aRequest, aURI) { | |
this.processNewURL(aURI); | |
} | |
}; | |
window.fireTrimURL = fireTrimURL; | |
fireTrimURL.init(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment