Skip to content

Instantly share code, notes, and snippets.

@hensm
Last active August 6, 2018 12:46
Show Gist options
  • Save hensm/f1e28acd25e072acb63867ba6bc7b365 to your computer and use it in GitHub Desktop.
Save hensm/f1e28acd25e072acb63867ba6bc7b365 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE bindings>
<bindings xmlns="http://www.mozilla.org/xbl">
<binding id="urlbar" extends="chrome://browser/content/urlbarBindings.xml#urlbar">
<implementation>
<method name="formatValue">
<body><![CDATA[
const textNode = this.editor.rootElement.firstChild;
if (this.focused) return;
try {
const url = new URL(this._value);
if (/(http|https):/.test(url.protocol)) {
if (url.host.startsWith("www")) {
url.host = url.host.slice(4);
}
textNode.textContent = url.host;
}
} catch (err) {}
]]></body>
</method>
</implementation>
</binding>
</bindings>
#urlbar {
/* Place bindings.xml in the same folder as userChrome.css */
-moz-binding: url("bindings.xml#urlbar") !important;
}
@Jorsitska
Copy link

Jorsitska commented Aug 6, 2018

Hi!
Thanks so much for this! This is great :D

I was just wondering if you had any idea why this caused a bar to pop up at the top of the window?
capture d ecran 2018-08-06 a 14 27 33
I must admit, I would love it to look like the picture below:
capture d ecran 2018-08-06 a 14 27 05

This black bar on top is apparently caused by this url trick, as it disappears when removing your css snipet from userChrome.css
It looks so cool though, I'd love to have both the address bar show only the domain, and no black bar on top :P Hopefully you have some advice for this?

Anyway, thanks again, it's really cool 👌
Have nice day ^^

EDIT : Somehow, setting a custom URL as destination for opening new windows corrects this. I have no idea why, but it does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment