-
-
Save tingplenting/495586e63850329904d2 to your computer and use it in GitHub Desktop.
Auto Sort Pinterest Pins by Repins
This file contains hidden or 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
//Go to any page with pins (a board, your pins, search results, etc) and open JavaScript Console (Ctrl+Shift+J on windows OR option+command+J on mac) and paste in this code: | |
//sort by repins, adjust amount of pins/pages you want to collect first | |
var pages = 5; | |
var count = 0; | |
var mylist = []; | |
var timeout; | |
load(); | |
function load(){ | |
$('.Pin').each(function(){ | |
mylist.push( $(this)[0] ) | |
}); | |
$(window).scrollTop( $(document).height() ); | |
timeout = window.setTimeout(load, 4000); | |
count++; | |
if(count==pages){ | |
finish(); | |
} | |
} | |
function finish(){ | |
window.clearTimeout(timeout) | |
console.log(mylist.length); | |
var list = mylist.filter(function(f){ | |
if( $(f).find('.repinCountSmall').length>0 ){ | |
return f; | |
} | |
}); | |
console.log(list); | |
list.sort(function(a, b) { | |
var compA = Number( $(a).find('.repinCountSmall').text().trim() ); | |
var compB = Number( $(b).find('.repinCountSmall').text().trim() ); | |
return (compA == compB) ? 0 : (compA > compB) ? -1 : 1; | |
}); | |
$(".Grid").before('<div id="organized"/>').remove(); | |
$.each(list, function(idx, itm) { | |
$("#organized").append($(itm)); | |
}); | |
$('.Pin').css({'clear': 'both', 'position': 'static'}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment