not Logged in

yt-importer

The situation

I mainly use Youtube on my Android phone with Newpipe, what an awesome application.
As much as i love it i have a point that i don't like about it:

The problem

You can watch an subscribe everything which is localy stored in a database. There is a nice export / import feature which is awesome, the downside is you cant really import the subscripitions into youtube.
However this point is important for me as the least i want for a good content creator is to give him a subscription to please the all mighty youtube algorithm.

The idea

So i thought I could hack together a little tool to import the db to youtube. I know theres an youtube api, but there are limited api calls. So i choose the cheesy way and hacked together a webextension.

I never wrote a webextension nor javascript nor anything other, in this strange dark obfuscated cheesy cloud of web development.
So it is not even near to professional. But however it works.

Early tries

At first i had very different approaches, but i run always into the same problem called CORS restrictions.

The solution

Basically it reads the json file which includes the subscriptions. Then it opens the page and clicks the subscribe button via js.
It does this by spawning a main background script, opens the url from the json script, waits untill loaded, injects some js magic, searches the Subscribe element, checks if already subscribed, and if not invokes the click() function on the element.
This gets repeated until every url is done.
So as you can imagine, it takes a little bit of time to complete. Because of the immense slow page loading.
But you can start it and do more important stuff like drinking coffee until it the Extension is done.

Since the plugin is not signed you can only load it in debug mode, or use waterfox which alows the installation of unsigned addons.

Gittea