Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- copied from:
- https://pastebin.com/udFkAV7b
- - Updated this Mar 30, 2019 at 4:09 PM to accommodate the new "+" button
- - you have to go to the post first by clicking on the ellipses at the top right
- */
- raffleGiverAwayer = "gibiofficial";
- clickMoreIntervals = [800, 1200]; // click every 0.8 seconds to 1.2 seconds
- raffleGiverAwayer = raffleGiverAwayer.replace(/^@/, "")
- moreCommentsBtn = null;
- numClickMoreClicks = 1;
- lastNumEntries = null;
- doneClicking = false;
- function clickMoreComments() {
- setTimeout(function() {
- moreCommentsBtn = document.querySelector("div[class*=IwRSH] button[class*=afkep]");
- if(!moreCommentsBtn) {
- moreCommentsBtn = document.querySelector("ul[class*=k59kT] button[class*=sqdOP]");
- }
- if(numClickMoreClicks % 10 == 0) {
- totalElems = getNumGathered();
- // no more click more button
- if(moreCommentsBtn == null
- || (lastNumEntries != null && (typeof totalElems) == "number" && lastNumEntries == totalElems)
- ) {
- gShowSoFar = false;
- doneClicking = true;
- getAllListItems(false);
- return;
- }
- tmpLastNumEntries = getNumGathered();
- if((typeof tmpLastNumEntries) == "number") {
- lastNumEntries = tmpLastNumEntries;
- }
- }
- if((numClickMoreClicks + 1) % 5 == 0) {
- if(!gShowSoFar) {
- displayRaffleMsg(getNumGathered() + " elements gathered so far", 450, 45);
- }
- }
- if(moreCommentsBtn) {
- if(moreCommentsBtn.getAttribute("disabled") == null) {
- evt = new MouseEvent("click", {view: window, bubbles: true, cancelable: true, clientX: 20});
- moreCommentsBtn.dispatchEvent(evt);
- }
- clickInterval = Math.random() * (clickMoreIntervals[1] - clickMoreIntervals[0]) + clickMoreIntervals[0];
- setTimeout(function() {
- if(!gShowSoFar) {
- clickAllViewReplies();
- }
- }, clickInterval);
- } else {
- doneClicking = true;
- getAllListItems(false);
- }
- numClickMoreClicks++;
- }, 250);
- }
- // get number of elements gathered so far
- function getNumGathered() {
- tmpLastNumEntries = document.querySelectorAll("ul[class*=Mr508] li[class*=rUo9f]").length;
- if((typeof tmpLastNumEntries) == "number") {
- if(tmpLastNumEntries == 0) {
- tmpLastNumEntries = document.querySelectorAll("ul[class*=k59kT] li[class*=gElp9]").length;
- }
- if((typeof tmpLastNumEntries) == "number") {
- tmpLastNumEntries2 = document.querySelectorAll("ul[class*=TCSYW] li[class*=rUo9f]").length;
- if((typeof tmpLastNumEntries2) == "number") {
- tmpLastNumEntries += tmpLastNumEntries2;
- }
- return tmpLastNumEntries;
- }
- }
- return false;
- }
- // click all the View replies buttons
- numMoreReplyClicks = 0;
- function clickAllViewReplies(lastRepliesLeft) {
- viewReplyBtns = document.querySelectorAll("ul[class*=TCSYW] li[class*=_61Di1] button[class*=sqdOP]");
- replyCmntsLeft = 0;
- for(repI = 0; repI < viewReplyBtns.length; repI++) {
- replyBtn = viewReplyBtns[repI];
- if(replyBtn.getAttribute("disabled") == null) {
- if(replyMatches = replyBtn.innerText.match(/View\ replies\ \((\d+)\)/i)) {
- replyCmntsLeft += parseInt(replyMatches[1]);
- evt = new MouseEvent("click", {view: window, bubbles: true, cancelable: true, clientX: 20});
- replyBtn.dispatchEvent(evt);
- break;
- }
- }
- }
- if(lastRepliesLeft != undefined && lastRepliesLeft == replyCmntsLeft) {
- replyCmntsLeft = 0;
- }
- // all replies so far clicked
- if(replyCmntsLeft == 0) {
- // move replies iterator up
- viewRepliesItr = viewReplyBtns.length;
- // continue clicking clickMoreComments
- setTimeout(function() {
- if(!gShowSoFar) {
- clickMoreComments();
- }
- }, clickInterval);
- } else {
- setTimeout(function() {
- if(replyCmntsLeft == undefined) {
- replyCmntsLeft = 0;
- }
- clickAllViewReplies(replyCmntsLeft);
- }, clickInterval);
- }
- if(numMoreReplyClicks % 5 == 0) {
- if(!gShowSoFar) {
- displayRaffleMsg(getNumGathered() + " elements gathered so far", 450, 45);
- }
- }
- numMoreReplyClicks++;
- }
- function getAllListItems(showAllComments) {
- unfilteredList = [];
- filteredList = [];
- excludedList = [];
- if(showAllComments == undefined) { showAllComments = true; }
- gShowAllComms = showAllComments;
- mainItems = document.querySelectorAll("ul[class*=Mr508] li[class*=rUo9f]");
- if(mainItems.length == 0) {
- mainItems = document.querySelectorAll("ul[class*=k59kT] li[class*=gElp9]");
- }
- replyItems = document.querySelectorAll("ul[class*=TCSYW] li[class*=rUo9f]");
- for(listCommentsType = 0; listCommentsType < 1; listCommentsType++) {
- if(listCommentsType == 0) {
- listItems = mainItems;
- } else if(listCommentsType == 1) {
- listItems = replyItems;
- }
- for(listI = 0; listI < listItems.length; listI++) {
- if(raffleUserHref = listItems[listI].querySelector("a[href]")) {
- raffleUser = raffleUserHref.getAttribute("href");
- raffleUser = raffleUser.replace(/\//g, "");
- comment = listItems[listI].innerText;
- comment = comment.replace(/[\r\n]+/g, " ");
- comment = comment.replace("@" + raffleGiverAwayer, "[at]" + raffleGiverAwayer);
- comment = comment.replace(/\d+w\d+\ likes?Reply\s*$/, "");
- comment = comment.replace(/\d+wReply\s*$/, "");
- comment = comment.replace(/\d+d\d+\ likes?Reply\s*$/, "");
- comment = comment.replace(/\d+dReply\s*$/, "");
- comment = comment.replace(/\d+h\d+\ likes?Reply\s*$/, "");
- comment = comment.replace(/\d+hReply\s*$/, "");
- comment = comment.replace(/\d+mReply\s*$/, "");
- comment = comment.replace(/\d+m\d+\ likes?Reply\s*$/, "");
- comment = comment.trim();
- unfilteredList.push({user: raffleUser, "comment": comment});
- }
- }
- }
- unfilteredList.sort(function(a, b) {
- if(a.user < b.user) { return -1; }
- else if(a.user > b.user) { return 1; }
- else {
- if(a.comment < b.comment) { return -1; }
- else if(a.comment > b.comment) { return 1; }
- else return 0;
- }
- });
- lastUser = null;
- lastComment = null;
- for(listI = 0; listI < unfilteredList.length; listI++) {
- if(lastComment == null || lastComment != unfilteredList[listI].comment) {
- if(!showAllComments) {
- if((lastUser == null || lastUser != unfilteredList[listI].user)
- // has tagged another user
- && (otherUserMatch = unfilteredList[listI].comment.match(/@([^@\s]{3,})(\s|$)/))
- // other user is not them
- && unfilteredList[listI].user.indexOf(otherUserMatch[1]) == -1
- // other user is not Gibi
- && otherUserMatch[1].indexOf(raffleGiverAwayer) == -1
- ) {
- filteredList.push(unfilteredList[listI]);
- } else {
- excludedList.push(unfilteredList[listI]);
- }
- lastUser = unfilteredList[listI].user;
- } else {
- filteredList.push(unfilteredList[listI]);
- }
- }
- lastComment = unfilteredList[listI].comment;
- }
- outputStr = "";
- for(listI = 0; listI < filteredList.length; listI++) {
- comment = filteredList[listI].comment;
- comment = comment.replace(/\[at\]/g, "@");
- outputStr += "@" + comment + "\r\n";
- }
- displayRaffleMsg(outputStr, 450, 450, showAllComments);
- }
- gShowAllComms = true;
- gShowSoFar = false;
- function displayRaffleMsg(outputStr, dispWidth, dispHeight, showCheckBoxAll) {
- if(dispWidth == undefined) { dispWidth = 400; }
- if(dispHeight == undefined) { dispHeight = 400; }
- dispHeight = Math.max(60, dispHeight);
- clearDispMsg();
- dispResultsDiv = document.createElement("div");
- dispResultsDiv.setAttribute("id", "dispResDiv");
- dispResultsDiv.setAttribute("style", "position: fixed; left: 400px; min-width: " + dispWidth + "px; min-height: " + dispHeight + "px; background-color: rgb(210,235,2240); z-index: 10000; padding: 5px;");
- dispResultsDiv.innerHTML = "click + press [enter] to make this go away";
- if(gShowSoFar && !doneClicking) {
- dispResultsDiv.innerHTML += "<br /><br />" + getNumGathered() + " elements gathered so far"
- }
- showResultsTextArea = document.createElement("textarea");
- showResultsTextArea.setAttribute("id", "dispResText");
- showResultsTextArea.setAttribute("spellcheck", "false");
- showResultsTextArea.setAttribute("style", " z-index: 10001; min-width: " + (dispWidth - 20) + "px; min-height: " + (dispHeight - 40) + "px; margin: 14px; overflow: auto; background-color: rgb(210,235,224);");
- mainCardDiv = document.querySelector("div[class*=ltEKP] div[class*=wKWK0]");
- if(mainCardDiv == null) {
- mainCardDiv = document.querySelector("div[class*=z8cbW] div[class*=RqtMr]");
- }
- if(mainCardDiv == null) {
- mainCardDiv = document.querySelector("div[class*=KlCQn]");
- }
- mainCardDiv.before(dispResultsDiv);
- dispResultsDiv.append(showResultsTextArea);
- // show checkbox for showing all
- if(outputStr.length > 32) {
- checkBoxAllDiv = document.createElement("div");
- checkBoxAllDiv.setAttribute("style", "width: 450px; display: inline-block; padding: 5px;");
- checkBoxAllElem = document.createElement("input");
- checkBoxAllElem.setAttribute("type", "checkbox");
- checkBoxAllElem.setAttribute("onchange", "checkUncheckShowAll();");
- checkBoxAllElem.setAttribute("id", "showall_comments_checkbox");
- checkBoxAllElem.setAttribute("style", "vertical-align: middle;");
- if(showCheckBoxAll) {
- checkBoxAllElem.setAttribute("checked", "checked");
- }
- checkBoxAllLabel = document.createElement("label");
- checkBoxAllLabel.setAttribute("for", "showall_comments_checkbox");
- checkBoxAllLabel.setAttribute("style", "vertical-align: middle;");
- checkBoxAllLabel.innerHTML = " Show All";
- checkBoxAllDiv.append(checkBoxAllElem);
- checkBoxAllDiv.append(checkBoxAllLabel);
- dispResultsDiv.append(checkBoxAllDiv);
- }
- // show checkbox for showing everything so far
- if(!doneClicking) {
- checkBoxSoFarDiv = document.createElement("div");
- checkBoxSoFarDiv.setAttribute("style", "width: 450px; display: inline-block; padding: 5px;");
- checkBoxSoFarElem = document.createElement("input");
- checkBoxSoFarElem.setAttribute("type", "checkbox");
- checkBoxSoFarElem.setAttribute("onchange", "showSoFar();");
- checkBoxSoFarElem.setAttribute("id", "showsofar_checkbox");
- checkBoxSoFarElem.setAttribute("style", "vertical-align: middle;");
- checkBoxSoFarLabel = document.createElement("label");
- checkBoxSoFarLabel.setAttribute("for", "showsofar_checkbox");
- checkBoxSoFarLabel.setAttribute("style", "vertical-align: middle;");
- if(gShowSoFar) {
- checkBoxSoFarLabel.innerHTML = " Resume";
- } else {
- checkBoxSoFarLabel.innerHTML = " Show Elements";
- }
- checkBoxSoFarDiv.append(checkBoxSoFarElem);
- checkBoxSoFarDiv.append(checkBoxSoFarLabel);
- dispResultsDiv.append(checkBoxSoFarDiv);
- }
- showResultsTextArea.value = outputStr;
- }
- function showSoFar() {
- gShowSoFar = ((gShowSoFar)? false : true);
- if(gShowSoFar) {
- getAllListItems(false);
- } else {
- clearDispMsg();
- // resume clicking
- clickMoreComments();
- displayRaffleMsg(getNumGathered() + " elements gathered so far", 450, 45);
- }
- }
- function checkUncheckShowAll() {
- gShowAllComms = ((gShowAllComms)? false : true);
- allShowAllElems = document.querySelectorAll('[id=showall_comments_checkbox]');
- cboxAll = allShowAllElems[ allShowAllElems.length - 1 ];
- if(gShowAllComms) {
- getAllListItems(true);
- } else {
- getAllListItems(false);
- }
- }
- document.addEventListener("keyup", function(evt){
- // [enter]
- if(evt.keyCode == 13) {
- if(document.querySelectorAll("div[id*=dispResDiv]").length) {
- clickMoreComments = function() { };
- clickAllViewReplies = function() {};
- clearDispMsg();
- }
- }
- });
- function clearDispMsg() {
- allDispDivs = document.querySelectorAll("div[id*=dispResDiv]");
- for(allDivI = 0; allDivI < allDispDivs.length; allDivI++) {
- dispIdElems = allDispDivs[allDivI].querySelectorAll("[id]");
- for(dispIdElemsI = 0; dispIdElemsI < dispIdElems.length; dispIdElemsI++) {
- dispIdElems[dispIdElemsI].parentNode.removeChild(dispIdElems[dispIdElemsI]);
- }
- allDispDivs[allDivI].style.display = "none";
- allDispDivs[allDivI].parentNode.removeChild(allDispDivs[allDivI]);
- }
- }
- clickMoreComments();
Add Comment
Please, Sign In to add comment