
Chrome Extension Programming: Illustrating a Basic Survival Skill - djent
http://karpathy.ca/myblog/2013/11/23/chrome-extension-programming-illustrating-a-basic-survival-skill-with-a-twitter-case-study/
======
glass_of_water
If all you want to do is execute your own js on a certain web page, you can
just use greasemonkey or another userscript extension for your browser instead
of writing a whole new extension each for each script.

Greasemonkey also appears to provide an interface for peristent local storage
as well. [1]

[1]
[http://wiki.greasespot.net/GM_setValue](http://wiki.greasespot.net/GM_setValue)

~~~
johnpmayer
The lay user is probably more likely to install a chrome extension than code.
Then again, I don't know if greasemonkey has gotten more lay-friendly
recently.

~~~
anaphor
All they'd have to do is click a link that says "install this script" and then
gm prompts you to install it.

------
kbenson
I've taken to using a simple server on a public IP that serves different JS
based on the referrer, and a bookmark for inserting a script tag in the
current page.

It doesn't auto run, but it is easy test, install on a new system (just a
bookmark!), and extend with extra behavior that can be centralized.
Additionally, an update immediately affects all clients.

~~~
krapp
You can drop scripts directly into the page context using Greasemonkey too.
Its 'sandbox' is pretty easy to break out of.

------
jrstanley
It looks like this kind of practice is quite popular. I recently created a
Chrome extension to extend Airbnb listings to show crime statistics and nearby
photos from Flickr.

I've shared it on the Chrome web store and GitHub on the off-chance it's of
interest to anyone else [https://chrome.google.com/webstore/detail/crime-
stats-and-ph...](https://chrome.google.com/webstore/detail/crime-stats-and-
photos-in/maokdkhncjmdmnloddgiokhjfckhbmmd)

~~~
dawson
OT You're not from Shoreditch, by chance?

~~~
jrstanley
Nope, I'm not too far from Birmingham.

------
conradev
> "I wanted to share a few examples of a powerful skill that I’ve been
> gradually picking up over the last year. It is simply the ability to quickly
> hack together custom browser extensions in Chrome and using them to
> customize my favorite websites."

Having this ability on every platform you use can be very powerful indeed,
which is why I always have a jailbroken/rooted phone to customize[1].

[1] [http://www.cydiasubstrate.com](http://www.cydiasubstrate.com)

------
Aardwolf
I do this too, though often with bookmarklets or with a plugin that runs JS on
certain URLs.

One annoyance though is when the website changes their code. E.g. often CSS
class names are shortened/compiled and will change with every update of the
website.

Does anyone have tips how to handle that, that is, ways to get the right
element without depending on the exact classname?

------
TheCowboy
I also have a personalized extension I use for several sites and general
browsing.

For viewing news.ycombinator.com on my larger monitor, I have it add 25% left
and right margins. I also have it enlarge the article titles regardless of
screen size so I don't have to zoom every time.

If you already know JavaScript, then it's really convenient and easy to pick
up.

------
ProCynic
I did one for work, to create github issues from trello cards. It was a pretty
easy speed up of our project management workflow.

[https://chrome.google.com/webstore/detail/trello-to-
github-i...](https://chrome.google.com/webstore/detail/trello-to-github-
issue/mcdgcblepfepgcjfjmhhdhoapahpeaob?hl=en)

------
oddshocks
"That’s the passive aggressive look of Twitter telling you that there are two
more tweets to show, but also refusing to actually show them. That would be
too useful to their users. Instead, they want you to stop what you’re doing
and click the button to load the new tweets."

I dunno, I actually like that feature.

~~~
karpathy
Interesting, Based on my own discussions with friends and my own experience,
it's considered strictly annoying and done likely to save bandwidth or
something. Can you explain what you like about it?

~~~
oddshocks
I like knowing which tweets I've read. If it says that there are new tweets,
can click it and see the new tweets appear. If they just appeared on the feed,
I wouldn't know as easily which tweets are new. Does that make sense? I guess
I just like being able to load the new tweets on-demand.

------
nswanberg
Chrome Dev Tools have become powerful enough to do some decent debugging for
extensions, but does anyone know if it can be used to create them? If there is
some sort of sandboxing to prevent such things, how much code would have to be
changed to have Chrome join the list of self-extensible systems?

~~~
eli
You can already write dev tools extensions. Or did you mean something else?
[http://developer.chrome.com/extensions/devtools.html](http://developer.chrome.com/extensions/devtools.html)

~~~
nswanberg
That's cool but I meant the ability to get an idea for an extension, create
it, and load it without leaving Chrome. Chrome already has Codemirror and some
ability to store files using snippets, so why not extend that to create
things?

I realize this an exceptional use case but it'd be great to see Chrome fit
Steve Yegge's QWAN concept, where one of the ideas is that a system should be
modifiable and extendible without rebooting, much like Emacs (Chrome is so
close to being there it hurts, but is likely intentionally prevented from
working that way).

~~~
eli
Ah, now I understand. I believe the Stylebot extension lets you live-edit a
page and then save the edits. Don't know about things more complicated than
CSS though.

~~~
nswanberg
Thanks. I'll take a look at Stylebot. I'm pretty convinced what I'm looking to
do isn't possible with default Chrome, but it might be, and I'd guess that I'm
not the first person to wonder this.

