Last active
July 28, 2023 15:05
-
-
Save robfrawley/b4b70049dc1d02c5bb72f5c1603d1e2f to your computer and use it in GitHub Desktop.
Tool Army Community Tools
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
// | |
// | |
// LAST RUN: 2023-07-23 | |
// LIKES | |
// | |
// | |
const handleExcept = (exception) => { | |
console.log('Caught an exception: ', exception); | |
}; | |
const querySelects = (selector) => { | |
return Array.from(document.querySelectorAll(selector)); | |
}; | |
const rmDomElement = (element) => { | |
return element.parentNode.removeChild(element); | |
}; | |
const padLen = (val, size = 3, char = ' ') => { | |
return String(typeof val == 'object' ? val.length : val).padStart(size, char); | |
}; | |
const socialClicks = () => { | |
const sliceRandom = (arr, max, min) => { | |
return arr.slice(0, arr.length > max ? getRandomInt(max, min) : arr.length); | |
}; | |
const clickElement = (element) => { | |
return element.click(); | |
}; | |
const postElementsLocated = querySelects('div.improvised_like_link[like-type=""]:not(.like-disable)'); | |
const postElementsToClick = sliceRandom(postElementsLocated, 30, 5); | |
console.log('[socialClicks] Clicked "' + padLen(postElementsToClick.length) + '" of "' + padLen(postElementsLocated.length) + '" post social buttons ...'); | |
try { | |
postElementsToClick.forEach(clickElement); | |
} catch(e) { | |
handleExcept(e); | |
} | |
return postElementsToClick.length; | |
}; | |
const postRemovals = (percent = 0.4, minimum = 20) => { | |
let postingElements = querySelects('div.card-parent-div'); | |
let postingDelCount = Math.max(Math.floor(postingElements.length * percent), 0); | |
if (postingDelCount > postingElements.length) { | |
postingDelCount = postingElements.length; | |
} | |
if ((postingElements.length - postingDelCount) < minimum) { | |
postingDelCount = Math.max(postingElements.length - minimum, 0); | |
} | |
postingElements.slice(0, postingDelCount).forEach(rmDomElement); | |
console.log('[postsRemoval] Removed "' + padLen( | |
postingDelCount | |
) + '" of "' + padLen( | |
postingElements | |
) + '" posts ...'); | |
let commentElements = querySelects('div.grid-item.listMessages'); | |
let commentDelCount = Math.max(Math.floor(commentElements.length * percent), 0); | |
if (commentDelCount > commentElements.length) { | |
commentDelCount = commentElements.length; | |
} | |
if ((commentElements.length - commentDelCount) < minimum) { | |
commentDelCount = Math.max(commentElements.length - minimum, 0); | |
} | |
commentElements.slice(0, commentDelCount).forEach(rmDomElement); | |
console.log('[postsRemoval] Removed "' + padLen( | |
commentDelCount | |
) + '" of "' + padLen( | |
commentElements | |
) + '" comments ...'); | |
}; | |
const scrollToBott = async () => { | |
let scrollToPosition = document.body.scrollHeight; | |
try { | |
console.log('[scrollToBott] Jump to "' + padLen(scrollToPosition, 12) + '" scroll position ...'); | |
window.scrollTo(0, scrollToPosition); | |
} catch(e) { | |
handleExcept(e); | |
} | |
}; | |
const scrollUpABit = async () => { | |
let scrollAtPosition = Math.floor(document.documentElement.scrollTop || document.body.scrollTop); | |
let scrollToPosition = scrollAtPosition - 100; | |
try { | |
//console.log('[scrollUpABit] Jump to "' + padLen(scrollToPosition, 12) + '" scroll position (from "' + padLen(scrollAtPosition, 12) + '" scroll position) ...'); | |
window.scrollTo(0, scrollToPosition); | |
} catch(e) { | |
handleExcept(e); | |
} | |
}; | |
const scrollClicks = async () => { | |
postRemovals(); | |
scrollToBott(); | |
socialClicks(); | |
}; | |
//------------------------------------------------------ | |
const intervalMilliseconds = 2000; | |
const scrollClicksInterval = setInterval( | |
scrollClicks, Math.max(Math.floor(intervalMilliseconds * 1.00), 1000) | |
); | |
const scrollUpABitInterval = setInterval( | |
scrollUpABit, Math.max(Math.floor(intervalMilliseconds * 0.80), 1000) | |
); | |
//------------------------------------------------------ | |
try { clearInterval(scrollClicksInterval); } catch(e) { console.log('ERROR:scrollClicksInterval', e); } | |
try { clearInterval(scrollUpABitInterval); } catch(e) { console.log('ERROR:scrollUpABitInterval', e); } |
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
// | |
// | |
// LAST RUN: 2023-07-23 | |
// COMMENTS | |
// | |
// | |
const padLen = (val, size = 3, char = '0') => { | |
return String(typeof val == 'object' ? val.length : val).padStart(size, char); | |
}; | |
const querySelects = (selector) => { | |
return Array.from(document.querySelectorAll(selector)); | |
}; | |
const shuffleArray = (array) => { | |
try { | |
for (var i = array.length - 1; i > 0; i--) { | |
var j = Math.floor(Math.random() * (i + 1)); | |
var temp = array[i]; | |
array[i] = array[j]; | |
array[j] = temp; | |
} | |
return array; | |
} catch(e) { | |
handleExcept(e); | |
} | |
}; | |
const handleExcept = (exception) => { | |
try { | |
console.log('Caught an exception: ', exception); | |
console.log('CLEARING INTERVAL! ...'); | |
clearInterval(submitDefComInterval); | |
} catch(e) { | |
console.log('ERROR:', e); | |
} | |
}; | |
const removePostElement = (e, i) => { | |
try { | |
let element = jQuery(e); | |
let comment = jQuery(element.parent().parent()); | |
let posting = jQuery(comment.prev()); | |
console.log('[removed-' + padLen(i, 4) + ']', comment); | |
comment.remove(); | |
posting.remove(); | |
} catch(e) { | |
handleExcept(e); | |
} | |
}; | |
const subDefaultCommentElement = (e, i) => { | |
try { | |
let outter = jQuery(e); | |
let inputs = jQuery(outter.children('div[data-maxlength]').children('div')); | |
let button = jQuery(outter.children('button')); | |
let eMusic = ['🎵', '🎵', '🎶', '🎧', '🎸', '🎤', '🥁']; | |
let eTools = ['🔧', '🔧', '🔨', '🔩']; | |
let eFires = ['🔥', '🔥', '💣', '💥', '🎉']; | |
let emojis = shuffleArray(eMusic)[0] + ' + ' + shuffleArray(eTools)[0] + ' = ' + shuffleArray(eFires)[0]; | |
inputs.html(emojis); | |
inputs.focus(); | |
button.click(); | |
console.log('[clicked-' + padLen(i, 4) + ']', outter); | |
setTimeout(removePostElement, 4000, outter, i); | |
} catch(e) { | |
handleExcept(e); | |
} | |
}; | |
const submitDefCom = (size = 10) => { | |
try { | |
let elementList = querySelects('div.comment-form-outer > form').slice(1, size + 1); | |
elementList.forEach((e, i) => { | |
let milliseconds = Math.max(1600 * i, 100); | |
console.log('[submitDefCom] Dispatching commenter action "' + padLen( | |
i + 1, 2 | |
) + '" of "' + padLen( | |
size > elementList.length ? elementList.length : size, 2 | |
) + '" in "' + padLen( | |
milliseconds, 5 | |
) + '" milliseconds ..."') | |
setTimeout(subDefaultCommentElement, milliseconds, e, i + 1); | |
}); | |
setTimeout(scrollToBott, 21000); | |
setTimeout(scrollUpABit, 21500); | |
setTimeout(scrollUpABit, 22000); | |
setTimeout(scrollUpABit, 22500); | |
setTimeout(scrollUpABit, 23000); | |
setTimeout(scrollUpABit, 23500); | |
} catch (e) { | |
handleExcept(e); | |
} | |
}; | |
const scrollToBott = () => { | |
try { | |
let scrollToPosition = document.body.scrollHeight; | |
console.log('[scrollToBott] Jump to "' + padLen( | |
scrollToPosition, 4 | |
) + '" scroll position ...'); | |
window.scrollTo(0, scrollToPosition); | |
} catch(e) { | |
handleExcept(e); | |
} | |
}; | |
const scrollUpABit = () => { | |
try { | |
let scrollAtPosition = Math.floor(document.documentElement.scrollTop || document.body.scrollTop); | |
let scrollToPosition = scrollAtPosition - 40; | |
console.log('[scrollUpABit] Jump to "' + padLen( | |
scrollToPosition, 4 | |
) + '" scroll position from "' + padLen( | |
scrollAtPosition, 4 | |
) + '" scroll position ...'); | |
window.scrollTo(0, scrollToPosition); | |
} catch(e) { | |
handleExcept(e); | |
} | |
}; | |
//------------------------------------------------------ | |
const intervalMilliseconds = 25000; | |
submitDefCom(); | |
const submitDefComInterval = setInterval( | |
submitDefCom, intervalMilliseconds | |
); | |
//------------------------------------------------------ | |
try { clearInterval(submitDefComInterval); } catch(e) { console.log('FAILUED: submitDefComInterval'); }; | |
//------------------------------------------------------ | |
const intervalMilliseconds = 22500; | |
const submitDefComInterval = setInterval( | |
submitDefCom, Math.max(Math.floor(intervalMilliseconds * 1.00)) | |
); | |
const scrollToBottInterval = setInterval( | |
scrollToBott, Math.max(Math.floor(intervalMilliseconds * 4.00), 1000) | |
); | |
const scrollUpABitInterval = setInterval( | |
scrollUpABit, Math.max(Math.floor(intervalMilliseconds * 0.33), 1000) | |
); | |
//------------------------------------------------------ | |
try { clearInterval(submitDefComInterval); } catch(e) { console.log('FAILUED: submitDefComInterval'); }; | |
try { clearInterval(scrollToBottInterval); } catch(e) { console.log('FAILUED: scrollToBottInterval'); }; | |
try { clearInterval(scrollUpABitInterval); } catch(e) { console.log('FAILUED: scrollUpABitInterval'); }; |
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
// | |
// | |
// LAST RUN: 2023-07-23 | |
// JQUERY INJECTOR | |
// | |
// | |
const initializeJQuery = () => { | |
const jq = document.createElement('script'); | |
jq.src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'; | |
jq.addEventListener('load', (event) => { | |
console.log('## Enabling jQuery no-conflict mode ...'); | |
window.jQuery.noConflict(); | |
}); | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
console.log('## Injected jQuery into document ...'); | |
} | |
initializeJQuery(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment