Created
February 12, 2020 14:45
-
-
Save amerkay/614a28d271da440eee601b30058c4d25 to your computer and use it in GitHub Desktop.
Pocket Explore Bookmarklet, filter last 5 years & sort the results by saved count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TO USE: | |
// Copy/Paste to https://www.minifier.org/ then paste into a bookmark | |
javascript: (function() { | |
// ==== set these to your desirable limits ==// | |
var days_ago_limit = 5 * 365; | |
var min_saves = 50; | |
//===========================================// | |
var listContainer = $("#best_of_list ul.portal_list"); | |
var articleLi = $("ul.portal_list li.item"); | |
articleLi.sort(function(a, b) { | |
var saves_a = parseInt($(".save_count", a).text().match(/\d+/)[0]), | |
saves_b = parseInt($(".save_count", b).text().match(/\d+/)[0]); | |
// console.log("sort: saves a " + saves_a + ", saves b " + saves_b) | |
if (saves_a > saves_b) { | |
return -1; | |
} else if (saves_a < saves_b) { | |
return 1; | |
} else { | |
return 0; | |
} | |
}) | |
.detach() | |
.appendTo(listContainer); | |
articleLi.filter(function(index) { | |
if ($(".read_time", this).text() === "") { | |
return true; | |
} | |
if (parseInt($(".save_count", this).text()) < min_saves) { | |
return true; | |
} | |
var days_ago = (new Date() - Date.parse($(".read_time", this).text())) / (24 * 60 * 60 * 1000); | |
// console.log("filter: index " + index + ", days_ago " + days_ago) | |
return days_ago > days_ago_limit || days_ago < 0; | |
}) | |
.remove(); | |
$("html > body").append( | |
"<p id='amers-notice' " + | |
"style='color: red; position:fixed; top:55px; right:10px; z-index:999; font-size:11px; background-color:white;'>" + | |
"Filtered out articles older than " + days_ago_limit + | |
" days and less than "+ min_saves +" saves & sorted by saves count!</p>" | |
); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment