flamebyrd: (Default)
flamebyrd ([personal profile] flamebyrd) wrote in [community profile] ao3some2012-06-17 10:26 am
Entry tags:

Pinboard bookmarklet for AO3 works

I edited the default Pinboard bookmarklet (the button you put in your browser bookmarks to let you quickly add links to Pinboard) so that it will grab the tags and summary from AO3 and include those in the Pinboard tags/description.

Would anybody who uses Pinboard for their bookmarks rather than AO3 be interested in that if I posted it?

I made a generator for the bookmarklet to allow people to choose which tags to include and so on. http://random.fangirling.net/fun/ao3/bookmarklet.html

(I tried to do the same for Delicious but it doesn't look like I can pass tags to it.)
saekhwa: Asian woman with short black hair & arms outspread and text that reads: 'free' (still an awkward girl with cute shoes)

[personal profile] saekhwa 2012-06-17 05:39 pm (UTC)(link)
OMG YES PLEASE?

This would be so amazing and save on so much time. (I'm, um. A little too thorough with my tags, so to speak, and trying to capture that data has been a PITA in more ways than one.)
saekhwa: Asian woman with short black hair & arms outspread and text that reads: 'free' (totally awesome)

[personal profile] saekhwa 2012-06-17 07:21 pm (UTC)(link)
Oh wow, this is the coolest ever. There are ticky box options! *stares in starry-eyed wonder*

Thank you so, so much for sharing! :D
snakeling: Statue of the Minoan Snake Goddess (Default)

[personal profile] snakeling 2012-06-17 05:44 pm (UTC)(link)
Yes please! Also, would you consider making one that only grabs the summary and not the tags, because I prefer to use mine :)
msilverstar: (Default)

[personal profile] msilverstar 2012-06-17 06:26 pm (UTC)(link)
ETA: thanks!

Also thanks for disclosing the jquery, I'm hoping that my little stream is not interesting enough for Google analytics.
Edited 2012-06-17 19:20 (UTC)
msilverstar: Viggo and Sean Bean, laughing, from the Empire Awards, Feb 2009 (viggo-sean bean 09)

[personal profile] msilverstar 2012-06-17 07:25 pm (UTC)(link)
I just really appreciate knowing, so thanks again.
lian: Klavier Gavin, golden boy (Default)

[personal profile] lian 2012-06-17 06:19 pm (UTC)(link)
*grabby hands* oooh that would be so, so useful!
azurelunatic: Vivid pink Alaskan wild rose. (Default)

[personal profile] azurelunatic 2012-06-17 08:46 pm (UTC)(link)
My particular setup uses If This Then That to glue Pinboard to Twitter, via the private tag ".twitter", which can be anywhere in my tags. I want to include that by default. I'm going to stare at the code for a bit to see how that should go in. :)
azurelunatic: Vivid pink Alaskan wild rose. (Default)

[personal profile] azurelunatic 2012-06-17 08:50 pm (UTC)(link)
Oh, awesome, thanks!

I've been playing around in Notepad a bit, but since I don't really know what I'm doing, I'm running afoul of the separator. (It's still fun to play with; yay hacking at things!) *more enthusiasm than skill*
azurelunatic: Vivid pink Alaskan wild rose. (Default)

[personal profile] azurelunatic 2012-06-18 01:03 am (UTC)(link)
Thanks! Hooray!
talimenios: (Default)

[personal profile] talimenios 2012-06-18 02:10 am (UTC)(link)
You are beyond awesome. Thank you so much.
stepps: stylised leaves and white flower on dark grey background (Default)

[personal profile] stepps 2012-06-18 12:24 pm (UTC)(link)
you = awesome!
southerly: (Default)

[personal profile] southerly 2012-06-18 06:24 pm (UTC)(link)
This is amazing, thanks so much!

Is there any way to also include the author as a tag?
Edited 2012-06-18 18:25 (UTC)
southerly: (Default)

[personal profile] southerly 2012-06-18 10:42 pm (UTC)(link)
Sorry! The bookmarklet is already wonderful and it is not a problem if I continue to add the author manually. That said, a choice for username or pseud sounds like a good idea.
southerly: (Default)

[personal profile] southerly 2012-06-21 01:42 pm (UTC)(link)
It's wonderful! This will really streamline my bookmarking. Thanks again!
annchi: Xie Lian with soft expression. (Kitten/Squirrel)

[personal profile] annchi 2012-06-18 06:57 pm (UTC)(link)
This is so very useful! Thank you!
hermitsoul: Archive of Our Own pirate logo icon (* ao3: stultiloquentia)

[personal profile] hermitsoul 2012-06-19 04:25 am (UTC)(link)
This is very awesome! Do you mind if I add it to the Cool Stuff page on the FAQs?
hermitsoul: life is good icon (* life is good: unexpectedbox)

[personal profile] hermitsoul 2012-06-21 08:10 am (UTC)(link)
Yay! *is selfishly glad about this addition*
azurelunatic: Vivid pink Alaskan wild rose. (Default)

[personal profile] azurelunatic 2012-12-31 04:50 am (UTC)(link)
I discovered an entertaining new failure mode. For a work like http://archiveofourown.org/works/575365/ (Jeeves & Wooster, tagged as if Bertie were doing the tagging himself, completely delightful and containing about a hundredweight of cucumbers), the valiant attempt to include all tags results in a woeful "Request URI is too long".

I'm planning to add a bookmarklet that does *not* attempt to pull in ALL THE TAGS, but if you can figure out how to make it cap the tags when it's going to overflow...
lezzerlee: Cat with glasses (Default)

[personal profile] lezzerlee 2013-12-09 07:42 am (UTC)(link)
This is perfect, almost exactly what I was looking for. The only thing that could be better is if it included tags. Or if bookmarking on AO3 automatically send it to your pinboard along w/your bookmark comment. But that's probably near impossible w/o it being a feature of AO3. This is the next best thing!
Edited 2013-12-09 07:46 (UTC)

[personal profile] exclamations 2020-09-15 04:59 am (UTC)(link)
I know it's been ages since you posted this tool, but I started playing with it last night because it was driving me crazy that the summary feature would lose line breaks on a lot of fic because of inconsistent html used in the blockquote. I ended up with the code below, after banging my head for awhile. I suspect I will need to add more replacements to the list as I encounter more paragraph formatting, but this currently gives me reliable line breaks in my fic summaries!

I also added some modifications so that I will always only get the Fic Title and Author in the title, and also strip out any extraneous parts of the url, since I only ever want to bookmark the base AO3 url.

Sorry if any of this is clumsily done - I've never played with javascript before, but I thought I'd share what I came up with anyway.

javascript:(function($){
var q=location.href;
var base = q.split("\/");
q = base[0] + "\/\/" + base[2] + "\/" + base[3] + "\/" + base[4];

var p=document.title; 
var parts = p.split("-");
if ( parts[1].startsWith(" Chapter")) {parts[1] = parts[2]}
p = parts[0] + "-" + parts[1];

var d="";
if(document.getSelection){ 
	d=document.getSelection();
}
if ( d=="" ) {
	d+=$(".summary blockquote.userstuff").html() ;
	d=d.replace(/<\/p><p>/g, '\n\n');
	d=d.replace(/<\/p>/g, '\n');
	d=d.replace(/<p>|<i>|<\/i>|<b>|<\/b>/g, '');
	d=$.trim( d );
}

var options = {"wordcount_format_text":"(%words% words)","series_include_format_text":"[%series%]"};
if ( d != '' ) { d += '\n' }
let series = $(".work.meta .series .position").map(function() { return $.trim($( this ).text()) }).get().join( ", " );
if ( series != '' ) {
	series = options.series_include_format_text.replace('%series%', series );
	d += '\n' + series; 
} 

var wc = options.wordcount_format_text.replace('%words%', $(".stats dd.words").text() );
if ( d != '' ) { d += '\n' }
d += wc; 

void(open("https://pinboard.in/add?url=" + encodeURIComponent(q) + "&description=" + encodeURIComponent(d) + "&title=" + encodeURIComponent(p), "Pinboard", "toolbar=no,width=700,height=350"));
})(jQuery);

[personal profile] exclamations 2020-12-02 09:53 pm (UTC)(link)
I not sure if others might be interested in Markdown; I've never cared about the rest of the summary formatting aside from line breaks.

After further iteration, here is what I'm using now for my bookmarklet:

javascript:(function($){
var q=location.href;
var base = q.split(/[/#?]/);
if ( base[3] == "collections" ) {
	base[3] = base[5];
	base[4] = base[6];
}
q = base[0] + "\/\/" + base[2] + "\/" + base[3] + "\/" + base[4];

var p=document.title; 
var parts = p.split("-");
if ( parts[1].startsWith(" Chapter")) {
	parts[1] = parts[2]
}
p = parts[0] + "-" + parts[1];

var d="";
if(document.getSelection){ 
	d=document.getSelection();
}
if ( d=="" ) {
	d+=$(".summary blockquote.userstuff").html() ;
	d=d.replace(/<\/p><p>/g, '\n\n');
	d=d.replace(/<\/p>/g, '\n');
	d=d.replace(/<br>/g, '\n');
	d=d.replace(/<.*?>/g, '');
	d=d.replace(/&nbsp;/g, ' ');
	d=$.trim( d );
}

var options = {"wordcount_format_text":"(%words% words)","series_include_format_text":"[%series%]"};
let series = $(".work.meta .series .position").map(function() { return $.trim($( this ).text()) }).get().join( ", " );
if ( series != '' ) {
	series = options.series_include_format_text.replace('%series%', series );
	d += '\n\n' + series; 
} 

var wc = options.wordcount_format_text.replace('%words%', $(".stats dd.words").text() );
if ( d != '' ) { d += '\n' }
d += wc; 

void(open("https://pinboard.in/add?url=" + encodeURIComponent(q) + "&description=" + encodeURIComponent(d) + "&title=" + encodeURIComponent(p), "Pinboard", "toolbar=no,width=700,height=350"));})(jQuery);

Figuring out the RegExp syntax helped me get rid of most of the html code I don't care about, and my latest addition was to get rid of the occasional &nbsp;s I was seeing and strip out collections from the URL. I'm still very grateful for the base code you provided, because I never would have bothered to figure this stuff out without it.