Created
October 15, 2018 16:01
-
-
Save ultimape/88420952e26196789e618858e100c4f6 to your computer and use it in GitHub Desktop.
Pinterest Board Linkifier - tool to makes it easier to open up all the links in Pinterest board.
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
/* | |
* Pinterest Board Linkifier | |
* | |
* This tool makes it easier to open up all the links in pinterest board. | |
* Tested in Google Chrome October 10th, 2015. | |
* | |
* It automatically scrolls to the bottom of the page until no more pins are loaded. | |
* | |
* Then it replaces the page with a list of links to all the pins. | |
* | |
* On clicking a link, it is opened in a new tab (hold control to open in background), and the link is removed automatically to avoid opening duplicates. | |
* | |
* ---- | |
* | |
* To use this script: | |
* 1) load a board. | |
* 2) copy all the text here and paste it into the browser's console. | |
* 3) press the [enter] key on your keyboard. | |
* 4) wait. | |
* | |
* | |
* I hearby release this under the MIT License. | |
* | |
*/ | |
/* Configure these variables to change how the scrolling behaves. | |
* You may need to give more or less depending on your screen size | |
* and internet connection speed. | |
*/ | |
var scroll_time = 1500; // the delay between scrolling | |
// 1000 = 1 second | |
var scroll_ammount = 6000; // how much to scroll, in pixels | |
var get_page_height = function () { | |
return Math.max( | |
document.body.scrollHeight, | |
document.body.offsetHeight, | |
document.documentElement.clientHeight, | |
document.documentElement.scrollHeight, | |
document.documentElement.offsetHeight | |
); | |
} | |
var old_height = 0; | |
var new_height = get_page_height(); | |
var get_page_links = function () { | |
console.log(""); | |
console.log("Compiling a list of pin links."); | |
var a=''; | |
let myDiv = document.createElement("div"); | |
var link_count = 0; | |
for(var ln=0;ln<document.links.length;ln++){ | |
var linkdata=document.links[ln]; | |
if(linkdata.href.includes("/pin/")){ // if the link points to a pin | |
link_count++; | |
var newLink = document.createElement("a"); | |
newLink.setAttribute('href',linkdata); | |
newLink.setAttribute('target',"_blank"); | |
newLink.setAttribute('style',"display:block;clear:left;"); | |
// this line makes the link disapear when clicked | |
newLink.onclick = function() { this.parentNode.removeChild(this);}; | |
newLink.appendChild(document.createTextNode(linkdata)); | |
myDiv.appendChild(newLink); | |
} | |
} | |
console.log("Found "+link_count+" Pins."); | |
console.log("Clearing the page"); | |
while (document.body.hasChildNodes()) | |
{ | |
document.body.removeChild(document.body.firstChild); | |
} | |
console.log("Adding compiled links to the bottom of page!") | |
document.body.appendChild(myDiv); | |
console.log("Done adding links.") | |
console.log(""); | |
console.log("Be sure to ctrl+click to open in background."); | |
} | |
var page_loading_tool = function() { | |
new_height = get_page_height() | |
var height_difference = new_height - old_height | |
if( height_difference > 0 ) { | |
old_height = new_height; | |
console.log("Height Changed by "+height_difference+", Scrolling down by "+ scroll_ammount); | |
window.scrollBy(0,scroll_ammount); | |
} else { | |
console.log("No height change detected, stoping scroll"); | |
clearInterval(scroll_throb); | |
get_page_links(); | |
} | |
} | |
var scroll_throb = setInterval(page_loading_tool, scroll_time); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment