Created
January 23, 2018 17:43
-
-
Save LudwikJaniuk/1f44d46536c7a596b80616a63e86c589 to your computer and use it in GitHub Desktop.
Print all the things in the momentum.earth active view you have opened as plaintext, nice and tidy, parseable.
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
// Momentum.earth active view scrapper | |
// Author: Ludvig Janiuk | |
// To have jQuery as "q" do this first: | |
var jq = document.createElement('script'); | |
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
// And then: | |
q = jQuery; | |
// Make sure all are unfolded first | |
// Will store output in string, no idea how to avoid newlines in console otherwise | |
var str = ""; | |
function printRecursive(depth, container) { | |
console.log("PrintRec", container); | |
for(var i = 0; i < depth; i++) { | |
str += " "; | |
} | |
str += container.find(".drop-title:first").html(); | |
str += "\n"; | |
var subs = container.find(".lake-wave:first").children(".lake-dropContainer:has(.drop-title)"); | |
for(var i = 0; i < subs.length; i++) { | |
var sub = subs.eq(i); | |
printRecursive(depth+1, sub); | |
} | |
} | |
var topContainer = q(".lake-wave:first").children(".lake-dropContainer:has(.drop-title)"); | |
topContainer.each((i, e) => printRecursive(0, q(e))); | |
// This will print all the things in the active view you have opened as plaintext, nice and tidy, parseable. | |
console.log(str); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment