GM script: Link to referenced image

Mar 20, 2006 19:42

I wrote a Greasemonkey script that will attempt to link references in comments to images in posts. So if someone has posted ten images, a comment like "I like the second to last picture" will contain a link back up to the ninth image. Like this:


Read more... )

Leave a comment

Comments 53

ladylamented March 21 2006, 00:10:02 UTC
Cool!

This will work great with postsecret.

Reply


e_richard March 21 2006, 01:33:59 UTC
Totally hot! :D

Reply


schwael March 25 2006, 15:45:19 UTC
it's not working for me on Firefox. :(

Reply

malesca March 25 2006, 20:03:57 UTC
What version Firefox, what version Greasemonkey, do you get any error message in the Tools > JavaScript Console, or whatever it's called? Please clear the console and then reload a page where the script should work, so that only related errors are included.

Reply

schwael March 27 2006, 15:28:10 UTC
oops, sorry. I didn't realize that successfully posted. I didn't actually try to download the thing. sorry.

Reply


janinedog March 25 2006, 19:37:34 UTC
It doesn't seem to work if the entry is on an entry page with a customized style (or perhaps mine in particular). Does it only work if you're using the LiveJournal-branded, original comment pages?

Reply

malesca March 25 2006, 20:19:39 UTC
Checked a post on your friends list and it did indeed not work. If LJ handled these things with just different stylesheets, rather than letting browsing schemes and customized styles change the actual markup, it'd make things a lot easier. :/

I fixed support for all three browsing schemes as the differences were minimal and easy to study, but I'm simply not familar enough with customized styles to know how to find comments and pictures-in-posts with any possible style. Will look into it when I find the time, which might be right away if the info is readily available.

Reply

janinedog March 25 2006, 20:30:59 UTC
Yeah, unfortunately there's no possible way you could make this work on all styles, since how the entry markup is made is totally customizable (to paid users, anyway). Here's an idea, though I don't know if it's feasible: could you make some global variables at the top of your script that specify what HTML starts an entry/comment, ends an entry/comment, and whatever else your script requires to find images and comments about them? As long as you comment the variables well enough, I think those of us who care to make the script work on our own styles can probably change those variables and make it work. And the defaults can obviously be what you have now.

I haven't looked at your script and I'm not too good with JavaScript anyway, so I have no idea if this is possible or not. But it's an idea.

Reply

malesca March 25 2006, 20:34:25 UTC
Ah, that settles it, then. You could indeed modify the script (Tools > Manage User Scripts, select script, Edit) yourself to fit your specific comment style - the variables xpImages and xpComments right at the top of the script are XPath expressions that tell the script where to find the post images and the comments.

XPaths are not as tricky as they may look, and I think anyone capable of making a template could probably figure it out using Google and the XPath Checker Firefox extension.

Reply


ilyanep March 26 2006, 03:52:19 UTC
Good script. Just wanted to point out that Opera supports GM too, which is really cool.

That first image is pretty cool. That 1st one. Yeah.

Reply

ilyanep March 26 2006, 03:53:06 UTC
Wait only after 10 images? aww

Reply

malesca March 26 2006, 07:37:00 UTC
Regarding your Opera comment, the script works in Opera 9 but not 8. Though Opera supports GM scripts, obviously it's not always a perfect match. Had to tinker to get it working in 9.

Not sure what you mean about "only after 10 images"? The script only kicks in when the original post contains two pictures or more, since there is no point in other cases. This community post only contains one image, but try http://malesca.livejournal.com/24357.html?thread=188197#t188197

Reply

ilyanep March 26 2006, 15:04:08 UTC
Oh...I got the imprssion from the wording of your post that it was 10. And yes, I did check out that test post you have. This is pretty cool.

And yes, I am using Opera 9 :)

Reply


Leave a comment

Up