Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sadeghbarati/9b90800b80c58ed76c73a9cd028ab1cc to your computer and use it in GitHub Desktop.
Save sadeghbarati/9b90800b80c58ed76c73a9cd028ab1cc to your computer and use it in GitHub Desktop.
YouTube Auto Subscriber which can be used to transfer your subscriptions from one account to another.
/*
* DESCRIPTION
* This script will go through all the subscription buttons on the YouTube page you execute it on, and subscribes to the ones that
* you're not subscribed to yet.
* A random delay is added to each subscription request, this is due to the fact that YouTube starts blocking subscriptions after
* a certain number of consecutive requests. Randomising the delays should trick the detection into thinking it's a valid user doing
* the requests.
*
* HOW TO USE
* Navigate to the page containing the channels you would like to subscribe to. (The subscribe button should be visible!)
* A good example is "https://www.youtube.com/user/<your_old_channel>/channels", make sure you set this information as public
* on your old channel
* Make sure the whole page is loaded by scrolling down and pressing "Load More" if applicable
* Open the developer console (On Google Chrome this is Ctrl+Shift+J)
* Copy paste the script below and press enter
* The script will start executing and showing you what it's doing in the developer console
* Wait until the script has finished
* This could take up to (amount_of_channels * 3 seconds)
*
* IMPORTANT
* When the script finishes all channels should be subscribed to, it is advised that you scroll down and check the last subscription
* button to verify this. YouTube starts blocking subscription requests when it detects them as 'fake', which could happen with this
* script. If that happens, run the script again after a few hours and it should continue where it ended last time
*
* The chance is high that your old channel has been subscribed to too, so you may want to unsubscribe from that one manually
*/
function doPreProcessing($x)
{
if($subscriptionButtons[$x].dataset.isSubscribed === undefined || $subscriptionButtons[$x].dataset.isSubscribed === false)
{
$newSubscriptions.push($subscriptionButtons[$x]);
console.log("#" + ($x+1) + " of " + $subscriptionButtons.length + " will be subscriped to.");
}
else
{
console.log("Skipping #" + ($x+1) + " of " + $subscriptionButtons.length + ", already subscribed.");
}
}
function doSubscription($x, $delay)
{
setTimeout(function()
{
$newSubscriptions[$x].click();
console.log("Subscribed to #" + ($x+1) + " of " + $newSubscriptions.length);
if($x == ($newSubscriptions.length-1))
{
console.log("Script finished.");
console.log("All channels should be subscribed to, it is advised that you scroll down and check the last subscription button to verify this. YouTube starts blocking subscription requests when it detects them as 'fake', which could happen with this script. If that happens, run the script again after a few hours and it should continue where it ended last time.")
}
}, $delay);
}
// Select subscription buttons
$subscriptionButtons = document.getElementsByClassName("yt-uix-subscription-button");
$newSubscriptions = [];
// Pre-process found buttons
for(var $x = 0; $x < $subscriptionButtons.length; $x++)
{
doPreProcessing($x);
}
$delay = 0;
// Subscribe to channels
for(var $x = 0; $x < $newSubscriptions.length; $x++)
{
console.log("\n\nWe will now subscribe to " + $newSubscriptions.length + " channels.");
$delay += (3000 * Math.random());
doSubscription($x, $delay);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment