Skip to content

Instantly share code, notes, and snippets.

@KristerV
Last active August 31, 2018 12:53
Show Gist options
  • Save KristerV/873bf14e9dc73aeed0d7db11b257fb79 to your computer and use it in GitHub Desktop.
Save KristerV/873bf14e9dc73aeed0d7db11b257fb79 to your computer and use it in GitHub Desktop.

Revisions

  1. KristerV revised this gist Jan 1, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ExpandAllFacebookGroup.js
    Original file line number Diff line number Diff line change
    @@ -51,7 +51,7 @@ procedure = function() {
    console.log("Finished procedure")
    setTimeout(function(){
    startOver()
    }, 1000 * 60 * 5)
    }, 1000 * 60 * 1)
    }
    }, 10000)
    }
  2. KristerV renamed this gist Jan 1, 2018. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions paste_into_console.js → ExpandAllFacebookGroup.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    /*
    This will expand all of the posts and comments that is in the view. It will take a lot of time!
    To use just paste this in your console (F12).
    */

    var previousScrollheight = 0
    @@ -15,6 +16,12 @@ scrollDown = function() {

    expandComments = function() {
    var foundLinks = 0

    document.querySelectorAll(':not(.text_exposed) > .text_exposed_hide > .text_exposed_link > .see_more_link').forEach(function(item) {
    item.click()
    foundLinks++
    })

    document.querySelectorAll('[href="#"]').forEach(function(item){
    var whitelist = ["See more", "More option", "more comment", "replie"]
    var blacklist = ["Hide", " hidden", "u_0_19"]
  3. KristerV revised this gist Jan 1, 2018. No changes.
  4. KristerV revised this gist Jan 1, 2018. 1 changed file with 19 additions and 25 deletions.
    44 changes: 19 additions & 25 deletions paste_into_console.js
    Original file line number Diff line number Diff line change
    @@ -14,29 +14,23 @@ scrollDown = function() {
    }

    expandComments = function() {
    setTimeout(function(){
    var foundLinks = 0
    document.querySelectorAll('[href="#"]').forEach(function(item){
    var whitelist = ["See more", "More option", "more comment", "replie"]
    var blacklist = ["Hide", " hidden", "u_0_19"]
    var blacklistRegexp = new RegExp(blacklist.join("|"), "i")
    var foundLinks = 0
    document.querySelectorAll('[href="#"]').forEach(function(item){
    var whitelist = ["See more", "More option", "more comment", "replie"]
    var blacklist = ["Hide", " hidden", "u_0_19"]
    var blacklistRegexp = new RegExp(blacklist.join("|"), "i")

    var whitelistResult = new RegExp(whitelist.join("|"), "i").test(item.innerHTML)
    var blacklistResultHTML = !(blacklistRegexp.test(item.innerHTML))
    var blacklistResultClass = !(blacklistRegexp.test(item.className))
    var blacklistResultId = !(blacklistRegexp.test(item.id))
    var whitelistResult = new RegExp(whitelist.join("|"), "i").test(item.innerHTML)
    var blacklistResultHTML = !(blacklistRegexp.test(item.innerHTML))
    var blacklistResultClass = !(blacklistRegexp.test(item.className))
    var blacklistResultId = !(blacklistRegexp.test(item.id))

    if (whitelistResult && blacklistResultHTML && blacklistResultClass && blacklistResultId) {
    foundLinks++
    item.click()
    }
    })
    console.log("foundLinks:", foundLinks)
    if (foundLinks > 0)
    expandComments()
    else
    startOver()
    }, 10 * 1000)
    if (whitelistResult && blacklistResultHTML && blacklistResultClass && blacklistResultId) {
    foundLinks++
    item.click()
    }
    })
    return foundLinks
    }

    procedure = function() {
    @@ -48,7 +42,9 @@ procedure = function() {
    procedure()
    } else {
    console.log("Finished procedure")
    startOver()
    setTimeout(function(){
    startOver()
    }, 1000 * 60 * 5)
    }
    }, 10000)
    }
    @@ -58,9 +54,7 @@ startOver = function() {
    if (tries < 10) {
    console.log("Try:", tries)
    tries++
    setTimeout(function(){
    procedure()
    }, 1000 * 60 * 5)
    procedure()
    } else {
    console.log("Finished whole program.")
    }
  5. KristerV revised this gist Jan 1, 2018. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions paste_into_console.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    /*
    This will expand all of the posts and comments that is in the view. It will take a lot of time!
    */

    var previousScrollheight = 0
    scrollDown = function() {
  6. KristerV created this gist Jan 1, 2018.
    66 changes: 66 additions & 0 deletions paste_into_console.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,66 @@

    var previousScrollheight = 0
    scrollDown = function() {
    var currentScrollheight = document.body.scrollHeight
    var canScroll = currentScrollheight - previousScrollheight
    previousScrollheight = document.body.scrollHeight
    if (canScroll !== 0) {
    window.scrollTo(0,currentScrollheight);
    }
    return canScroll
    }

    expandComments = function() {
    setTimeout(function(){
    var foundLinks = 0
    document.querySelectorAll('[href="#"]').forEach(function(item){
    var whitelist = ["See more", "More option", "more comment", "replie"]
    var blacklist = ["Hide", " hidden", "u_0_19"]
    var blacklistRegexp = new RegExp(blacklist.join("|"), "i")

    var whitelistResult = new RegExp(whitelist.join("|"), "i").test(item.innerHTML)
    var blacklistResultHTML = !(blacklistRegexp.test(item.innerHTML))
    var blacklistResultClass = !(blacklistRegexp.test(item.className))
    var blacklistResultId = !(blacklistRegexp.test(item.id))

    if (whitelistResult && blacklistResultHTML && blacklistResultClass && blacklistResultId) {
    foundLinks++
    item.click()
    }
    })
    console.log("foundLinks:", foundLinks)
    if (foundLinks > 0)
    expandComments()
    else
    startOver()
    }, 10 * 1000)
    }

    procedure = function() {
    setTimeout(function(){
    var scrolled = scrollDown()
    var expanded = expandComments()
    console.log("Scrolled:", scrolled, ". Expanded:", expanded)
    if (scrolled !== 0 && expanded !== 0) {
    procedure()
    } else {
    console.log("Finished procedure")
    startOver()
    }
    }, 10000)
    }

    var tries = 0
    startOver = function() {
    if (tries < 10) {
    console.log("Try:", tries)
    tries++
    setTimeout(function(){
    procedure()
    }, 1000 * 60 * 5)
    } else {
    console.log("Finished whole program.")
    }
    }

    startOver()