Hello, I just created an extension called SponsorBlock. It is a crowdsourced extension to block sponsor segments of YouTube videos.
The [source code](https://github.com/ajayyy/SponsorBlock) is fully open and the [database](https://sponsor.ajay.app/database.db) can be downloaded by anyone. I want to keep this as open as possible!
When you visit a YouTube video, it will check the database to see if anyone has made any submissions for this video. If so, the sponsored segment will automatically get skipped when you reach it.
[Image of the notice you receive (you can disable it)](https://i.imgur.com/hSfaVZD.gif)
Once the sponsorship is skipped, you can upvote or downvote this sponsorship and it will be recorded in the database.
Upvotes are considered in a very interesting way. Instead of just sending the top reported time, it uses an algorithm that is a little more complex, since some videos will have more than 1 sponsorship message. It will looks for all the "similar sponsors" (I'm using the word similar here like it is used in the term similar triangle). For each similar sponsor, only one will be sent to the user. A similar sponsor is one that is contained in eachother, so probably just similar times and one is slightly off.
#### Fancy vote distribution algorithm
In a system like that, one sponsor would get a few votes, and then the rest of the sponsors would never appear again, and could never get votes. I decided on using a more fancy algorithm that used a weighted random distribution based on a [square root function](https://i.imgur.com/xQ3kn0l.png). This formula makes small amount of votes (under 10), matter a lot, and makes the really large votes slowly not matter as much. This makes a newly submitted sponsor time always possible to be sent out to users to get votes. So, most users will get the best submission, but some users will get lesser votes submissions so that they can either be upvoted or downvoted. Submissions with less than -2 votes are ignored entirely.
You can read more about my algorithm [here](https://ajay.app/blog.html#voting-and-pseudo-randomness-or-sponsorblock-or-youtube-sponsorship-segment-blocker).
Anyone can submit sponsors, either by clicking on the button that is added to the YouTube player or by opening the extensions popup. The button in the YouTube player can be hidden if you would like. You click once to indicate the start of a sponsor, then click again to indicate the end. You can report as many sponsors as there are in the video. Just hit the submit button to submit.
#### What data is stored? (Because privacy)
The bare minimum. Everything stored can be downloaded from the link above if you want to see.
When you submit a sponsor, a few things are stored. The data for the sponsor, the video id are stored. Also, a hashed version of your user ID is stored with it. Your user ID is a randomly generated UUID generated by your browser. As well as these, a hashed + salted (5000 times) version of your ip address is saved. This is to be able to rate limit one ip sending way too much spam. Why is this hashed? Because the database public, if it was not hashed, everyone would have access to your IP address. After hashing it this many times, no one can reverse it and find what your actual IP address is, but I can still verify that the current connection is from that hashed ip. By hashing it 5000 times and salting it, brute forcing would take wayy too long to do (it takes around 20ms to generate 1 hash).
When you vote, your user ID and hashed ip is stored along with what you voted for.
As well as these, whenever you submit a sponsor, it tells the server and the server records one "view" on that sponsor. No IP data or userId data is collected for this. This is to make it so that you can see how many people you have helped and I can see how much the extension is being used. However, I perfectly understand why someone wouldn't want this data logged, so there is an option to disable this if you would like.
### Previous projects like this
In January, a group of people tried to do a similar thing, but instead of using other people's submissions to skip sponsor segments for everyone, they ran the data through a neural network. [Here are their projects](https://github.com/Sponsoff). Sadly, this project was abandoned.
I don't want something similar to happen to this project, that's why all this code is open-sourced and, most importantly, the database can be downloaded by anyone. The database may even be automatically backed up by archive.org! The database will always be available at https://sponsor.ajay.app/database.db. It is a sqlite database and can be opened in any sqlite database reading program.
#### How long has this taken me
I've been working on this for a little over 2 weeks now.
## Final thoughts
If you have any suggestions, feel free to tell me. If you know other places to post this, I would love to know. If this does not fit here, please tell me I can delete it.
You can find all my progress updates here: https://sponsor.ajay.app/news
You can contact me by email at dev @ ajay.app if you have any questions.
Feel free to join this Discord: https://discord.gg/QnmVMpU
Or follow on twitter: https://twitter.com/SponsorBlock