Count items in Pocket queue, favourites, archive…

1 min read

Use this script with Custom Javascript for websites plugin to inject jquery in your page to count and display items listed in your Pocket Queue.

As more items load when you scroll down, you can refresh the count hitting Control-Backspace.

 


// this counts <li> elements in the #queue less two (for elements which are not actually queue items)
function CountLis(){

    $('#children').remove();
    var $element = $("#queue");

    var numberOfChildren = $element.children().length - 2;
    var intext = '<li id="children" >Count: <span style="font-weight:bold; color: red;">'+numberOfChildren+'</span> Cntl-Backspace</li>';

    $( intext ).insertBefore( $( "#pagenav_searchicon" ) );

}

// delay a bit before loading the first count
window.setTimeout(function(){
  CountLis();
}, 3000);

// refresh using control + backspace
$(document).keydown(function(e) {
        if (e.keyCode == 8 && e.ctrlKey) {
            CountLis();
        }
 });