<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:ns0="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Random Thoughts (Posts about firefox)</title><link>https://carreau.github.io/</link><description /><ns0:link href="https://carreau.github.io/categories/firefox.xml" rel="self" type="application/rss+xml" /><language>en</language><lastBuildDate>Wed, 27 Oct 2021 20:18:01 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Open in Binder Browser Extension</title><link>https://carreau.github.io/posts/31-open-in-binder-browser-extension/</link><dc:creator>Matthias Bussonnier</dc:creator><description>&lt;div&gt;&lt;p&gt;Today I am please to announce the release of a first project I've been working
on for a bout a week: A Firefox extension to open the GitHub repository you are
visiting using MyBinder.org. &lt;/p&gt;
&lt;p&gt;If you are in a hurry, just head there to &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/open-with-binder/"&gt;Install version 0.1.0 for
Firefox&lt;/a&gt;.
If you like to know more read on. &lt;/p&gt;
&lt;p&gt;&lt;img alt="Binder Logo" src="https://carreau.github.io/posts/31-open-in-binder-browser-extension/img/binder_logo_128x128.png"&gt;&lt;/p&gt;
&lt;h3&gt;Back to Firefox.&lt;/h3&gt;
&lt;p&gt;I've been using Chrome for a couple of years now, but heard a lot of good stuff
about &lt;a href="https://www.rust-lang.org/en-US/"&gt;Rust&lt;/a&gt; and all the good stuff it has
done or &lt;a href="https://blog.mozilla.org/blog/2017/11/14/introducing-firefox-quantum/"&gt;Firefox&lt;/a&gt;. 
Ok that's a bit of marketing but it got me to retry Firefox (Nightly please),
and except for my password manager which took some week to update to the new
Firefox API, I rapidly barely used Chrome. &lt;/p&gt;
&lt;p&gt;&lt;img alt="Firefox Nightly Logo" src="https://carreau.github.io/posts/31-open-in-binder-browser-extension/img/Firefox_Nightly_Logo_2017.png"&gt;&lt;/p&gt;
&lt;h3&gt;MyBinder.org&lt;/h3&gt;
&lt;p&gt;I'm also spending more and more time working with the JupyterHub team on
&lt;a href="https://MyBinder.org"&gt;Binder&lt;/a&gt;, and see more and more developer adding binder
badges to their repository. Mid of last week I though:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;You know what's not optimal? It's painful to browse repositories that don't
have the binder badge on MyBinder.org, also sometime you have to &lt;em&gt;find&lt;/em&gt; the
badge which is at the bottom of the readme.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You know what would be great to fix that ? A button in the toolbar doing the
work for me.&lt;/p&gt;
&lt;h3&gt;Writing the extension&lt;/h3&gt;
&lt;p&gt;As I know Mozilla (which has a not so great &lt;a href="https://blog.mozilla.org/opendesign/mdns-new-design-beta/"&gt;new
design&lt;/a&gt; BTW, but
personal opinion) cares about making standard and things simple for their users,
I though I would have a look at the new
&lt;a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions"&gt;WebExtension&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;And 7 days later, after a couple of 30 minutes break, I present to you a
staggering 27 lines (including 7 line business logic) extension that does that:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;function&lt;/span&gt; &lt;span class="n"&gt;handleClick&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
    &lt;span class="n"&gt;browser&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tabs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="n"&gt;active&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="bp"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;currentWindow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="bp"&gt;true&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;tabs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;tabs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]})&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;tab&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;let&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tab&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hostname&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s1"&gt;'github.com'&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
      &lt;span class="n"&gt;console&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;warn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Open in binder only works on GitHub repositories for now.'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;};&lt;/span&gt;
      &lt;span class="n"&gt;let&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pathname&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="n"&gt;console&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;warn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'While you are on GitHub, You do not appear to be in a github repository. Aborting.'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="n"&gt;let&lt;/span&gt; &lt;span class="n"&gt;my_binder_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'https://mybinder.org/v2/gh/'&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="s1"&gt;'/'&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="s1"&gt;'/master'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="n"&gt;console&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Opening '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;'using mybinder.org... enjoy !'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="n"&gt;browser&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tabs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s1"&gt;'url'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;my_binder_url&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;

  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;console&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'(Re) loading open-in-binder extension.'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;browser&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;browserAction&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;onClicked&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;addListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;handleClick&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="n"&gt;console&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&#10084;&#65039; If you are reading this then you know about binder and javascript. &#10084;&#65039;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;console&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&#10084;&#65039; So you&lt;/span&gt;&lt;span class="se"&gt;\'&lt;/span&gt;&lt;span class="s1"&gt;re skilled enough to contribute ! We&lt;/span&gt;&lt;span class="se"&gt;\'&lt;/span&gt;&lt;span class="s1"&gt;re waiting for you on https://github.com/jupyterhub/ &#10084;&#65039;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;})()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can find the &lt;a href="https://github.com/Carreau/open-with-binder-firefox-extension/blob/a46c59199e6e5883ab4985064f6bddba5c6827d2/content_scripts/binderify.js"&gt;original source here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="Firefox Dev Logo" src="https://carreau.github.io/posts/31-open-in-binder-browser-extension/img/firefox-dev-logo.png"&gt;&lt;/p&gt;
&lt;p&gt;The hardest part was finding the API and learning how to package and set the
icons correctly. There are still &lt;a href="https://github.com/Carreau/open-with-binder-firefox-extension/issues"&gt;plenty of missing
features&lt;/a&gt;
and &lt;a href="https://github.com/Carreau/open-with-binder-firefox-extension/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22"&gt;really low hanging
fruits&lt;/a&gt;,
even if you have never written an extension before (hey it's my first and I
averaged 1-useful line/day writing it...).&lt;/p&gt;
&lt;h3&gt;General Feeling&lt;/h3&gt;
&lt;p&gt;Remember that I'm new to that and started a week ago.&lt;/p&gt;
&lt;p&gt;The Mozilla docs are good but highly varying in quality, it feels (and is) a
wiki. More opinionated tutorials might have been less confusing. A lot of
statements are correct but not quite, and leaving the choice too users is just
confusing. For example : you can use SVG or PNG icons, which I did, but then
some area don't like SVG (addons.mozilla.org), and the WebExtensions should work
on Chrome, but Chrome requires PNG. Telling me that I could use SVG was not
useful.&lt;/p&gt;
&lt;p&gt;The review of addons is blazingly fast (7min from first submissions to Human
approved). Apple could learn from that if what I've heard here and there is
correct..&lt;/p&gt;
&lt;p&gt;The submission process has way to many manual steps, I'm ok for first
submission, but updates, really ? I want to be able to fill-in all the
information ahead of time (or generate them) and then have a cli to submit
things. I hate filling forms online.&lt;/p&gt;
&lt;p&gt;The first submission even if marked Beta will not be considered beta. So
basically I published a 0.1.0beta1, then 0.1.0beta2 which did not trigger
automatic update because the beta1 was not considered beta. Super confusing. I
could "force" to see the beta3 page but with a warning that beta3 was an older
version than beta1 ? What ? &lt;/p&gt;
&lt;p&gt;There is still this feeling that this last 1% of polishing the process has not
been done (That's usually where Apple is know to shine). For example your store
icon will be resized to 64x64 (px) and display in a 64x64 (px) square but I have
a retina screen ! So even if I submitted a 128x128 now my icon looks blurry !
WTF !&lt;/p&gt;
&lt;h3&gt;You can contribute&lt;/h3&gt;
&lt;p&gt;As I said earlier there is a lot of low hanging fruits ! I went through the
process of figuring things out, so that you can contribute easily:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;detect if not on /master/ and craft corresponding binder URL&lt;/li&gt;
&lt;li&gt;Switch Icons to PNGs&lt;/li&gt;
&lt;li&gt;test/package for Chrome&lt;/li&gt;
&lt;li&gt;Add options for other binders than MyBinder.org&lt;/li&gt;
&lt;li&gt;Add Screenshots and descriptions to the Addon Store.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So see you
&lt;a href="https://github.com/Carreau/open-with-binder-firefox-extension"&gt;there&lt;/a&gt; !&lt;/p&gt;&lt;/div&gt;
&lt;/body&gt;&lt;/html&gt;

</description><category>binder</category><category>firefox</category><guid>https://carreau.github.io/posts/31-open-in-binder-browser-extension/</guid><pubDate>Wed, 22 Nov 2017 17:25:31 GMT</pubDate></item></channel></rss>