Hacker News new | past | comments | ask | show | jobs | submit login
Dotjs — hack the web (defunkt.io)
309 points by duck on June 29, 2011 | hide | past | favorite | 58 comments



This seems like it's a lot of overhead for what amounts, in terms of capability, to a reimplementation of greasemonkey. It also makes you implement finer controls on execution by url yourself, whereas greasemonkey has them in its syntax. The author states,

"GreaseMonkey user scripts are great, but you need to publish them somewhere and re-publish after making modifications. With dotjs, just add or edit files in ~/.js."

but this caveat is just as strong for files you maintain outside of your browser, and some browsers' implementations of userscripts/greasemonkeylikes actually have a similar filesystem-based model for managing scripts already.

While respectable, I had hoped to be more impressed by a tool that beckons me to "hack the web".


That's all true, but dotjs is only for Google Chrome on OS X.

Google Chrome on OS X has no such filesystem-based model for managing scripts.


You know that once a user script is installed in chrome you can edit the script.js file in the extension's directory on the fly. It's a little more work than simply putting a file in ~/.js but it doesn't require a HTTP server to function.


True, and this is why I love dotjs. Thanks for making it!

Maybe a good followup project would be to use some of the dotjs code to help make a filesystem-based GreaseMonkey system for Chrome, which would be just as easy to manage as dotjs scripts are.


So actually it's much worse than Greasemonkey.

Also, with GM you can just save the script with the same filename and it'll use that instead.

This project is 100% useless.


Unless you don't use Firefox and you tend to have a lot of dot files that you hack around with in your home directory. Then it starts to seem pretty awesome.


Chrome runs Greasemonkey-scripts, too. They are automatically converted to extensions in the background. Works very well. ( http://blog.chromium.org/2010/02/40000-more-extensions.html )

But I wouldn't call this useless. It's just another approach.


Yeah, already have greasemonkey and the only thing I have to do to "publish" files is to save them with the same name.

This project is a lot of work for zero benefit.



I've sneakily been using this for months on Hacker News itself- I just .hide() stories past around story #15. More signal, less noise. And it's just jQuery, so it's really easy to whip up.

Bonus points for it being so easy to share, too: https://github.com/holman/holman-js/blob/master/news.ycombin...


It's interesting how perspectives differ on what is considered noise. On the average day I start my browsing here around link 15, or even the new queue.

You're pretty much guaranteed to hear of anything hitting the front page anyway if it was meaningful to begin with. If not, it's probably some momentary obsession or buzzword bingo (say, "Google", "Social", "Facebook killer", "Privacy", "Product launch" to take an ephemeral example :))


I'll add bitcoin to that list.


don't forget the cloud!


and node.js


Same here. Mine:

1) sniffs out urls in submissions and auto-links them

2) adds comment thread folding.

https://github.com/sant0sk1/dotfiles/blob/master/js/news.yco...



I quickly scan http://hckrnews.com/ which makes sure I don't miss any upvoted story. It does have a lot of noise, but going through 20 or so articles since last time i looked doesn't take that long


I just look at the top 50% on hckrnews.com. That seems to work for me, even though I'm not usually after the buzzword-of-the-day stories.


I added CoffeeScript support if anyone's interested.

just change your file extension from .js to .coffee

https://github.com/eightbitraptor/dotjs/commit/20c97774eb29f...


Doesn't Chrome have builtin support for Greasemonkey scripts? How is this better? Is it just the convenience of having jQuery preloaded?


"GreaseMonkey user scripts are great, but you need to publish them somewhere and re-publish after making modifications."

Publish them where? I don't understand this. Whenever I change a user.js file and save it the browser updates it and it's ready to go next time the page reloads.

Side node: Scriptish is a fork of greasemonkey with many cool extras. https://addons.mozilla.org/en-US/firefox/addon/scriptish/


Requires Ruby? Why...


Chrome extensions can't access the local filesystem so we have to start a tiny webserver in the background.

If someone knows a way around this limitation, or a simpler webserver to require / embed, I would be thrilled. But so far this is the best I've found.


Did you investigate requesting the files directly from the filesystem, like "file:///home/monkey/.js/google.com.js".

You'd need to tell users to enable file access for the extension though chrome://extensions/, since that isn't enabled by default and users have to opt into it. I also don't know if there is a way to get the current user's homedir without hardcoding it.

Also: you're being super careful to not allow arbitrary reading of the filesystem, right? A good sanity check would be to ensure that realpath() of any file served is under ~/.js before handing it off.


ahahahahah what? Dude, do you work for Microsoft? "Well see, we just have to run MS-SQL server (DESKTOP OMG EXPRESS ENGINE) here, and then we run IIS on top of it to serve this file listing..."


He co-founded GitHub and is the CEO presently. That will be good enough for you?


It's a limitation of Chrome. This isn't the first time that someone tried to use a local webserver to do something that Chrome doesn't allow. IIRC, there was someone that used a webserver to implement a hacky version of It'sAllText! for Chrome.


It looks like Ruby is only needed for the file server. You could easily substitute a Python file server (cd .js; python -m SimpleHTTPServer 3131). You could use a remote Apache server for synchronizing your scripts. I agree that Ruby is a little overkill, but it is simple enough to run easily on a Mac, and it is extensible for hackers.


If you use your own server make sure you set the Access-Control-Allow-Origin header:

https://github.com/defunkt/dotjs/blob/master/bin/djsd#L26

(Also, Ruby comes with OS X (just like Python) so it seemed a sane choice.)


But Python comes with OSX and Ubuntu


But Ruby is the language the developer uses when doing something basic like this?


Python usually, as far as I can tell. Either language is fine, I just think these things should be done in something that comes pre-installed on more systems.


I mean, I knew Chris years ago and his language of choice was Ruby, and I don't think it's changed.

Sure basic install-ability is great, but I bet you this tool was made to satiate an itch he had, and he used the tools he's used to. Little apps like these aren't engineered. Just hacks, for hacks sake.


Feel free to fork the project and make it Python-based. defunkt works at Github and does most of his work in Ruby from what I can see.


Installing ruby on Ubuntu is easy. Most users of this kind of extension would probably know how.


Sounds like a relatively easy way to replace dependence on Ruby would be to just load the scripts directly from one's GitHub repo, where all your scripts can be easily synchronized.


See also jsshell[1] for Chrome. Press the button and you can run jQuery-powered JS on the fly, save snippets and run them, even automatically on regex-matched URLs.

[1] https://chrome.google.com/webstore/detail/kmgmkbicahmbceidoi...


I'm waiting for someone to build a social browser extension on top of something like this. Anyone could submit custom CSS/JS for a website and the most upvoted "theme" automatically gets loaded. Sure the JS security issues might be a nightmare, but the web would look soooo much prettier!



Great work! But I had some trouble getting it to run on my Mac.

I think it might be because I use VirtualHostX - http://clickontyler.com/virtualhostx/ - which alters my hosts file. I had to create a host - http://dotjs/ - pointing to my ~/.js/ folder - then edit the Extension JS to point the Ajax to http://dotjs/ instead of http://localhost:3131. A bit of pain but it might just be who this affects.


I think the ruby web server is not necessarily needed, simply change the dotjs.js's content to

$.get(chrome.extension.getURL("script/"+window.location.hostname+".js"), function(script){ eval(script); });

it will look for the js file in the extension directory instead of the local ruby web server, and this should work for any platform. To take the ~/.js convenience, a symlink in *inx system or shortcut in window will do the job.


Sweet! Believe it or not I've been actually looking for something like this for Chrome over the past couple of days so this is great.


The instructions given only work for Mac.


Should work fine in Linux too, from looking at the instructions.

(Firefox user here... This looks like a poor man's greasemonkey).


Nah, it tries to install some OS X "launch agent" thing. Should be quite simple to get it to work in Linux, but it doesn't yet.



I wrote a simliar extension for CSS.

It's free in the Chrome store: http://goo.gl/vWcqr


Reminded me a lot of Greasemonkey for FF.


greasemonkey scripts also work in chrome.


In fact, Chrome built them into the web browser so they work without installing any Greasemonkey extensions.


greasemonkey for chrome doesn't support the full thing @require for example


Awesome, exactly what I needed. I was just about to create yet another "inject X.js" bookmarklet.


Why does this need OSX?


It seems like a pretty trivial little hack - I think the only reason it really requires OS X is to launch the toy web server that serves the scripts.


Umm.. is there a way to run it on windows :( ?


Looks like you'll have to modify the Rakefile to use whatever Windows uses to launch the webserver. If you don't have ruby, you could probably write one in your local language of choice.


Sorry, how is this different to greasemonkey?


This just made my day, keep up the good work.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: