Recent posts by Johan Sundström

Subscribe to Recent posts by Johan Sundström 23 posts found

Aug 7, 2008
Johan Sundström 23 posts

Topic: Userscripts.org discussion / internal server error when trying to upload an iso8859-1 encoded file

Showing proper error messages is of course always a good idea, though. :-) "Scripts uploaded to userscripts.org must be saved as unicode encoded as utf-8; this script was not legal utf-8. If you do not know how to do that, we suggest you paste the script contents into the text area instead to let your browser do the work for you." for instance. (Henrik probably has ideas to further improve that suggestion; he is a whiz about user friendly docs.)

 
Aug 7, 2008
Johan Sundström 23 posts

Topic: Userscripts.org discussion / userscripts json/xml api url format

Scrooge: Yep; I somehow missed the whole part about filtering away all the non-header portions of the script.

 
Aug 7, 2008
Johan Sundström 23 posts

Topic: Userscripts.org discussion / internal server error when trying to upload an iso8859-1 encoded file

-1. Your user's report is not script encoding related; Greasemonkey stores your script as UTF-8 anyway.

Your request would only add brittleness to the us.o system, and/or complexity, if the site successfully implements a built-in automatically-convert-any-encoding-to-UTF-8 function, which is a feat that requires a fairly tall wizard hat to pull off.

Us.o core devs are mainly native speakers of ASCII, so their hack time is probably better spent on other issues than rather tricky I18N conversion you are probably more likely to get right on your side of the wire every time, than they on theirs.

Tip: If you already host the script on a remote url, in whichever encoding, use http://userscripts.org/scripts/show/31234 instead and click its load button to load its contents into the userscripts.org textarea.

 
Aug 6, 2008
Johan Sundström 23 posts

Topic: Userscripts.org discussion / userscripts json/xml api url format

ScroogeMcPump: Append "?" to the script installation URL, and you get exactly that, without any update of the script installation counter.

Also: woot! :-D *looks forward to seeing the domain propagate to name servers*

 
Aug 2, 2008
Johan Sundström 23 posts

Topic: Userscripts.org discussion / Versions & Diffs for a userscript

Awesome; Henrik dug up that I can pass any query parameter to opt out of the install countage. :-)

 
Aug 2, 2008
Johan Sundström 23 posts

Topic: Userscripts.org discussion / Versions & Diffs for a userscript

Also, linking the versions index (http://userscripts.org/scripts/versions/30750), next and prior diffs (when they exist) from the top and bottom portions of the diff page would be neat improvements.

I'd love to hack up some features for live clickage to fold/unfold the common sections into/out of view, but that is better done client side than server side. Is there any query parameter I can pass the install link, so xhr's don't count towards the installation counter?

 
Aug 2, 2008
Johan Sundström 23 posts

Topic: Userscripts.org discussion / Versions & Diffs for a userscript

I think e g http://userscripts.org/scripts/diff/30750/28294 would look better if you ran diff -wu instead; whitespace changes (newline ending style) aren't that interesting to show.

 
Jul 24, 2008
Johan Sundström 23 posts

Topic: Script development / Standard Function Library

alien_scum: I'd suggest renaming your xpath + css bastard (negative tonal value not really indentional, though I'd avoid that cross-breed myself) to something else; $xc, for instance.

It's a caustic tool to encounter for any seasoned XPath hacker, as it would mercilessly kill stuff like $X('//h1[.="Introduction"]'), as . is used the same way in XPath as in a unix path, for "current node", unlike in CSS.

I keep my own standard library of GM helpers here, by the way: http://ecmanaut.googlecode.com/svn/trunk/lib/gm/ (sorry about the lack of docs; I should blog more of them). For now, it's a treasure chest for those seasoned few that are read/write capable in the JS / DOM world.

 
Jul 19, 2007
Johan Sundström 23 posts

Topic: Ideas and script requests / Wikipedia click-to-inline footnotes

Thanks a ton! :-D

 
May 8, 2007
Johan Sundström 23 posts

Topic: Script development / Cannot intercept alert()

Feel free to hijack navigator.cookieEnabled if you want to architect your own, perhaps conditional, reply. As Henrik notes, it won't affect tests done at the top level script body though, as that code is executed as the page loads.

 
Mar 28, 2007
Johan Sundström 23 posts

Topic: Script development / For anybody having scope issues with GM_xmlhttpRequest

A great resource on the theory and practice of lexical closures and partial application is Brockman's Object-Oriented Event Listening through Partial Application in JavaScript. The title sets out to solve the same kind of issue under another set of circumstances (event listeners), but the solution and all understanding of the problem applies to those circumstances and yours alike. You'll have this problem in many similar situations until you understand how closures work in javascript, and then be rid of the issue.

Another elegant solution proposed there is turning your recipe into

Function.prototype.bind = function( thisObject ) {
  var method = this;
  var oldargs = [].slice.call( arguments, 1 );
  return function () {
    var newargs = [].slice.call( arguments );
    return method.apply( thisObject, oldargs.concat( newargs ));
  };
}

GM_xmlhttpRequest({
  method:'GET',
  url:'http://www.somewhere.com/something.xml',
  onload:myCallback.bind( { myVar:some_variable } )
});

// variables from the {...} literal above are now found in the `this' object:
function myCallback( request ) {
  alert( this.myVar );
  ...
}

This also allows you to pass additional function arguments to myCallback, bound in before the request argument, if you'd like to, perhaps like this:

var url = 'http://www.somewhere.com/something.xml';
GM_xmlhttpRequest({
  method:'GET',
  url:url,
  onload:myCallback.bind( {}, url, some_variable )
});

// 2nd onward argument to bind get prepended to the xhr callback's args:
function myCallback( url, myVar, request ) {
  alert( myVar );
  ...
}

 
Mar 14, 2007
Johan Sundström 23 posts

Topic: Userscripts.org discussion / Policy for disruptive scripts?

Flyne: That problem is unfortunately NP hard, and there is an endless number of obfuscation techniques a competent malicious script crafter could employ to dodge such detection. It's a race between black hats and black hat prevention code which black hats will always have the initiative in, and lots of very boring and unrewarding work which would A) flag or affect non-malicious, useful scripts like Book Burro, B) still require manual handling, C) require staff to partake that handling.

That's not to discourage you from participating to yourself write such code for advisory flag tags inviting particular scripts to peer review (once we have that system), merely suggesting that the present code maintainers are unlikely to go down that route themselves.

 
Mar 13, 2007
Johan Sundström 23 posts

Topic: Userscripts.org discussion / Policy for disruptive scripts?

I'm +1 on a minimal involvement policy, where us.o only takes preventive action against scripts that hurt the us.o site. Which is more or less what we have in practice already, with a rather heavy-weight value of "hurt".

Reasoning: we already offer commenting functionality for people to voice opinion against particular scripts, and inviting default practice of shutting down scripts deemed uncomfortable will mostly give us.o admins a work burden not related to improving us.o, which is bad. More in-depth reasoning of both points in this thread on the Greasemonkey-users list.

 
Feb 24, 2007
Johan Sundström 23 posts

Topic: Userscripts.org discussion / Commenting <&> quoting helper

I find it somewhat useful to be able to do things like

var panels = {
  scraper: { title:'Configuration' },
  exhibit: { title:'Exhibit' },
   facets: { title:'Facets' }
};
(which we apparently can't at the moment :-)), and that kind of thing is something we would get by sticking to HTML without more magic than filtering out dangerous tags or markup that would primarily enable people to post page layout breaking stuff. I'll probably do some sketching on things like this eventually, though, so don't feel pressured. :-)

And if we find it's not for us.o, it could hit a user script instead.

 
Feb 24, 2007
Johan Sundström 23 posts

Topic: Userscripts.org discussion / Commenting <&> quoting helper

http://www.elliotswan.com/postable/ is kind of nice (though implemented using ridiculous ajax techniques) when you post code and don't feel like doing the escaping by hand. A better yet less visual goodness hack doing the same is available at http://jy.xenweb.net/escaper/

I think it might be neat to could afford comment fields throughout the site an HTML escaping button. (It makes some sense actually doing this in the form of a user script, making the feature something you can get with any text area on any site, but that way has findability issues. :)

No idea yet of a neat way of presenting that button cruftlessly. We have about the best comment forms on the web at the moment, so keeping up the style is worthwhile. :-)

 
Feb 17, 2007
Johan Sundström 23 posts

Topic: Ideas and script requests / Favicon Replacer

Mark my links does that, among other things, and with a totally no-programming interface too. Install it, go to the site where you want to change favicons, use the bookmarklet, check the "Override original favicon" checkbox, click the google favicon, paste in your preferred favicon URL, click the "add link" icon on the right, click "Save changes".

Yes, that's a whole lot of clicking, but after that, all pages at www.google.com will use your favicon instead. Click the "Site" text if you want more hard-core tweaking, allowing you to change the matcher to be a regexp applied to the whole URL (if you perhaps wanted it only on pages below http://www.google.com/reader/, for instance).

 
Feb 17, 2007
Johan Sundström 23 posts

Topic: Userscripts.org discussion / External script hosting is gone!

Sounds on track to me. My wishlist:

  • Re-add the "update from URL" field, and prepopulate it with the original source location.
  • When updating:
    • download the script,
    • hash its contents (SHA-256, for instance),
    • compare the hash with already present content hash.
    • If different, update the "last modified" property shown for the script.
  • When we have some form of peer review / seals of approvement by other peers vouching for a script's non-maliciousness: Tie those to the hash of the script, rather than its id.
  • Optional great feature:
    • poll the external source at regular intervals.
    • when its hash changes from the site version, store (in columns of their own) its hash and poll time (unless same as last time polled).
    • Present on-site as something along the lines of "The original source location is more recent ($timestamp) than the one listed here." (and, when we have the peer review system, "Proceed with caution; certifications of non-maliciousness apply only for the version available on userscripts.org.")

Of course that is far too much text, but with a bit of polish it could become as good as "we help break your paragraphs and link your links", without losing too much relevant detail.

 
Feb 14, 2007
Johan Sundström 23 posts

Topic: Userscripts.org discussion / Server Configuration

I hope and presume the source code can be set up locally with a much less ambitious configuration? (For development and testing -- say, rails, webrick and sqlite?)

 
Feb 14, 2007
Johan Sundström 23 posts

Topic: Userscripts.org discussion / Tags in Userscripts.org

Another thought that struck me: also borrow flickr's idea of namespaced machine tags, allowing more structured folksonomies using ad-hoc namespaces. (Machine tags are namespace:key=value tags, such as site:hostname=userscripts.org.)

 
Feb 14, 2007
Johan Sundström 23 posts

Topic: Userscripts.org discussion / Tags in Userscripts.org

1: -1. With tld:s there are too many collisions for sites that are less one-site-rules-all than gmail.

2: +1. Very good. Slightly challenging to come up with a good UI for (with a tags field you can add multiple, space-separated, optionally "quoted multi-word tag" -- which happens to be the best possible UI base), but certainly doable. I might be up to the challenge of the front-end UI code, if someone else does the back-end code.

3: +0. Might be good.

4: Copy flickr's constraint on allowing a maximum of 75 tags for any user script.

 
Feb 13, 2007
Johan Sundström 23 posts

Topic: Userscripts.org discussion / Welcome to the new site!

It's just past midnight in sunny California, and site revamp heroes are sleeping after their relaunch marathon, but operators are standing by for your call. ;-)

 
Feb 13, 2007
Johan Sundström 23 posts

Topic: Ideas and script requests / Wikipedia click-to-inline footnotes

I once wrote up a rather neat footnote inliner for paulgraham.com articles, which lets you click the footnote reference and have a copy of it injected in the spot where the link was.

I would absolutely love the same functionality at Wikipedia.

 
Feb 13, 2007
Johan Sundström 23 posts

Topic: Userscripts.org discussion / Suggested house-keeping

In the site revamp, script pages, like everything else, have received some much needed love. The short descriptions of scripts (from data harvested off your scripts' @description tag in the userscript header) now appear in the summary views linking to scripts.

You might want to update your short summaries to actually be short, if they were not, so your script index does not look like a huge block of text, if it does (mine certainly does :-).