-
-
Save mia-riezebos/882d41acd5e648fe48303af1d72c24d1 to your computer and use it in GitHub Desktop.
Unfollow all on soundcloud
This file contains 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
// 1. go to your profile | |
// 2. click the "Following" count | |
// 3. open the browser console | |
// 4. copy and paste this code into the console | |
// 5. profit :3 | |
// (6. follow me on https://soundcloud.com/patchstep) | |
var scriptName = "unfollow-sc.js"; | |
var authorName = "Patch"; | |
var authorUrls = [ | |
"https://twitter.com/patchstep", | |
"https://soundcloud.com/patchstep", | |
"https://github.com/mia-cx" | |
]; | |
/** | |
* gets all the unfollow buttons on the page | |
* @returns {Array} - Array of buttons | |
*/ | |
function getButtons() { | |
let buttons = Array.prototype.slice.call( | |
document.getElementsByClassName("sc-button-follow") | |
); | |
buttons = buttons.filter((button) => { | |
return button.getAttribute("title") === "Unfollow"; | |
}); | |
return buttons; | |
} | |
/** | |
* click all buttons in passed array | |
* @param buttons - Array of buttons to unfollow | |
*/ | |
function unfollowAll(buttons) { | |
console.log("Unfollowing " + buttons.length + " users..."); | |
buttons.forEach((button) => { | |
button.click(); | |
}); | |
} | |
/** | |
* scrolls to the bottom of the page, to load more users | |
*/ | |
function loadMore() { | |
window.scrollTo(0, document.body.scrollHeight - 20); | |
} | |
/** | |
* simple credits log function... not essential to the rest of the script :) | |
*/ | |
function credits() { | |
console.log( | |
`%c${scriptName}%c\n\nthis unfollow script was made by %c${authorName}\n%c${authorUrls.join("\n")}`, | |
"font-family: 'Helvetica'; font-size: 6em; font-weight: bold; text-stroke: 2px #272d3b; color: #fffaf7;", | |
'font-size: 2em; color: #fffaf7;', | |
'font-size: 2em; color: #fffaf7; font-weight: bold;', | |
'font-size: 1em; color: #fffaf7; font-weight: bold;' | |
); | |
} | |
/** | |
* main function that calls the above functions | |
*/ | |
function main() { | |
credits(); | |
let buttons = getButtons(); | |
if (buttons.length === 0) { | |
console.log("No more users to unfollow..."); | |
return; | |
} | |
unfollowAll(buttons); | |
console.log("Loading more users..."); | |
loadMore(); | |
setTimeout(() => { | |
main(); | |
}, 5000); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment