[Greasemonkey] "Bloglines Keep All New Link" User script

Nicola Paolucci durden at gmail.com
Thu Jun 2 10:59:09 EDT 2005


Hi All,

While I find a permanent home for this useful small user script, I
release it to the world here.

It is my very first greasemonkey script so bear with me if you room
for improvement. Feedback is of course welcome!

ciao !
    Nick

// "Bloglines Keep All New Link" User script
// version 0.1 BETA!
// 2005-06-01
// Copyright (c) 2005, Nicola Paolucci
// Released under the BSD license
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.
//
// To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "Bloglines Keep All New Link", and click Uninstall.
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name Bloglines Keep All New Link
// @namespace http://www.durdn.net/greasemonkey
// @description Adds a new "keep all new" link to every blog page. If
you have a big list of entries in a blog and you are sure you will not
be able to read them in one session. You can click the "keep all new"
link and then untick the entries while you read them one by one.
// @include       http://www.bloglines.com/myblogs_display*
// ==/UserScript==

var embeddedjs = document.createElement("script");
embeddedjs.innerHTML = 'function xpath(query) {' +
    '    return document.evaluate(query, document, null,' +
    '                            
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);' +
    '}' +
    'function delay(gap){ /* gap is in millisecs */' +
    '    var then,now; then=new Date().getTime();' +
    '    now=then;' +
    '    while((now-then)<gap)' +
    '        {now=new Date().getTime();}' +
    '}' +
    'function checkAllKeepNewBoxes() {' +
    '    allElements = xpath("//input[@type = \'checkbox\']");' +
    '    for (var i = 0; i < allElements.snapshotLength; i++) {' +
    '        thisElement = allElements.snapshotItem(i);' +
    '        prms = thisElement.id.split("-");' +
    '        prms[0] = prms[0].substring(4,prms[0].length);' +
    '        thisElement.checked = true;' +
    '        markUnreadItem(prms[0],prms[1]);' +
    '        delay(1000);' +
    '    }' +
    '}';

function delay(gap){ /* gap is in millisecs */
    var then,now; then=new Date().getTime();
    now=then;
    while((now-then)<gap)
        {now=new Date().getTime();}
}

function xpath(query) {
    return document.evaluate(query, document, null,
        XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
}

function addKeepAllNewLink() {
    allElements = xpath("//ul[@class = 'channel_nav']/li");
    thisElement = allElements.snapshotItem(0);
    if (thisElement) {
        newli = document.createElement('li');
        newli.innerHTML = '<a
href="javascript:checkAllKeepNewBoxes()">keep all new</a>';
        thisElement.parentNode.insertBefore(newli, thisElement);
    }
}

(function() {
    if (document.title == "Bloglines | My Blogs") {
        document.body.insertBefore(embeddedjs, document.body.firstChild);
        addKeepAllNewLink();
    }
})();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bloglines-keepnew.user.js
Type: application/x-javascript
Size: 3069 bytes
Desc: not available
Url : http://mozdev.org/pipermail/greasemonkey/attachments/20050602/28cb06ae/bloglines-keepnew.user.js


More information about the Greasemonkey mailing list