Sunday, April 2, 2017

Move 'Read Later' articles to Feedly Board

This weekend were curious how to move all what is saved in feedly 'Read Later' to a custom Board. Just to make it fast tried to use Chrome DevTools and came out with awkward solution, but that appeared to be functioning, at least until feedly will update the code again.

Basically it ended up with a button that injects into popup that used to select the board.



This code creates a button element with parameters which is used

i=0; b=1; c=100;
var button = document.createElement('button');
  button.innerHTML = 'click me';
  button.onclick = function(){
  i=i+1
    document.querySelectorAll('.condensed-toolbar-icon.button-icon-only-micro.icon.icon-fx-save-to-knowledge-board-ios-md-black.tertiary')[c-i].click();

 setTimeout(function(){
 document.querySelectorAll('.popover')[1].style.display = "none"
 document.querySelectorAll('.item.item-add-remove.is-interactive.item-with-visuals')[1].appendChild(button)
 window.scroll(0,findPos(document.querySelectorAll('.item.item-add-remove.is-interactive.item-with-visuals')[1]));
 }, 1000);
  };

document.querySelectorAll('.item.item-add-remove.is-interactive.item-with-visuals')[b].appendChild(button)

Where 'c' should be set to the last saved article, since the script goes from the last article to top to mantain the same structure. Basically this could be used even for aka renaming the Boards, but it is just awkward solution and takes a lot of time, depending how many articles you have.

Before entering the code you need to know following:

1) Latest article number:
Just scroll to the last article and enter the following code and try to guess how many articles you may have, just put this code changing the number to the highest value, so it will show the result: 
document.querySelectorAll('.condensed-toolbar-icon.button-icon-only-micro.icon.icon-fx-save-to-knowledge-board-ios-md-black.tertiary')[30]


2) Which board to save the article to:
Click on 'Save to board' button and enter the code


document.querySelectorAll('.item.item-add-remove.is-interactive.item-with-visuals')[1]

Then hover on the output from DevTools and change the number to the one which matches board name you need to save articles to, change this in the initial code too, line 10.

3) Once you have changed 'c' variable and line 10 in the code, you can click 'Save to Board' on the last item in the list you need to save and enter the code in the DevTools, then you need to make sure that the custom button have appeared on the popup, see first image.

The code above uses function from an answer by AhhSirk Dasarp on one of stackoverflow questions:

//Finds y value of given object
function findPos(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        do {
            curtop += obj.offsetTop;
        } while (obj = obj.offsetParent);
    return [curtop];
    }
}

Just put this additional code and you are good to go to click on the custom button you have seen on the first image. This will automatically open another popup and move the view to it, you can click it again and again and it will save articles one after another to the board you have selected. This can been even fully automated by implementing an autoclicker, whreas there are many that could be used, for example Pulover's macro recorder. Just be sure to add some delay between clicks, so the data will load before it will initiate another click and in case you were too fast clicking, just enter line 10 into the DevTools to open the last popup anew to continue from the last unsaved article.

This has been said... awkward, but works and it is fast to implement.

No comments:

Post a Comment