Greasemonkey hack for CiteULike article removal

Programming — Alex @ 3:52 pm

One crucial feature that CiteULike lacks is the ability to remove entries en masse; the only way to remove several entries is to go to each entry’s page, click on delete, and confirm the deletion– that’s about 3 clicks per removal. Imagine if you want to remove *all* of your entries!

That was the problem I encountered as I attempted to clear my account of all the papers not related to my research, so I decided it’d be worth the time to write a little Greasemonkey script to remove all the entries. Unfortunately, in addition to being very out of practice with Javascript and the DOM, I’ve never used Greasemonkey before, so I ended up writing a two-script hack. The first script loads the first entry on my CiteULike library page, and the second script deletes any entry once its page is loaded; together they eliminate entries one by one until none are left. Inelegant, but much more inefficient than doing it by hand.

Here’s the code for the two scripts– just remember to retask them to point to your citeulike account, and to DISABLE under Greasemonkey or delete them after you’re done.

// ==UserScript==
// @name           First citeulike article
// @namespace      http://tangentspace.net
// @description    Loads first citeulike article
// @include        http://www.citeulike.org/user/swiftset
// ==/UserScript==
 
articlelist = document.evaluate("//div[@class='list']", 
document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, 
null).snapshotItem(0);
 
allarticles = document.evaluate("//a[@class='title']", 
articlelist, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, 
null);
 
document.location.href = allarticles.snapshotItem(0).href;
// ==UserScript==
// @name           Delete Citeulike Article on load
// @namespace      http://tangentspace.net
// @description    deletes any citeulike article on load of the article info page
// @include        http://www.citeulike.org/user/swiftset/article/*
// ==/UserScript==
 
allhidden = document.evaluate("//input[@name='user_article_id']", 
document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, 
null);
anelem = allhidden.snapshotItem(0);
 
document.location.href="http://www.citeulike.org/delete?user_article_id="
+anelem.value+"&"+"from=%2fuser%2fswiftset";

Possibly relevant posts:

0 Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2008 ChapterZero | powered by WordPress with Barecity