Skip to content

Instantly share code, notes, and snippets.

@mlnrDev
Last active August 12, 2023 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mlnrDev/b0949e9d3f2ba312b7523579976c9f31 to your computer and use it in GitHub Desktop.
Save mlnrDev/b0949e9d3f2ba312b7523579976c9f31 to your computer and use it in GitHub Desktop.
YouTube SponsorBlock Buttons
// ==UserScript==
// @name YouTube SB Buttons
// @namespace cane-sb-buttons
// @version 1.0.8
// @updateURL https://gist.githubusercontent.com/mlnrDev/b0949e9d3f2ba312b7523579976c9f31/raw/cane-sb-buttons.user.js
// @downloadURL https://gist.githubusercontent.com/mlnrDev/b0949e9d3f2ba312b7523579976c9f31/raw/cane-sb-buttons.user.js
// @description Useful buttons/redirects for SponsorBlock moderation. No need for bookmarklets!
// @author cane, original by Deedit
// @match https://www.youtube.com/*
// @icon https://sponsor.ajay.app/LogoSponsorBlockSimple256px.png
// @grant none
// ==/UserScript==
(function () {
var intv = setInterval(function () {
const x = document.getElementById('center');
if (!x) return false;
setupButtons();
clearInterval(intv);
}, 100);
})();
const youtube = 'https://youtu.be/';
const sbc_lock = 'https://mruy.github.io/sponsorBlockControl-sveltekit/lockcategories/?videoID=';
const sbc_browse = 'https://mruy.github.io/sponsorBlockControl-sveltekit/browse/?videoID='
const sbb_browse = 'https://sb.ltn.fi/video/';
const dab_browse = 'https://dearrow.minibomba.pro/video_id/'
const buttons = { // if you want to disable certain buttons, simply change "true" to "false"
'playlist': {
enabled: true,
title: 'Open video outside of playlist',
text: 'Playlist',
url: youtube
},
'sbc_lock': {
enabled: true,
title: 'Lock categories using SBC',
text: 'Lock',
url: sbc_lock
},
'sbc_browse': {
enabled: true,
title: 'Browse segments using SBC',
text: 'SBC Browse',
url: sbc_browse
},
'sbb': {
enabled: true,
title: 'Browse segments using SBB',
text: 'SBB',
url: sbb_browse
},
'dab': {
enabled: true,
title: 'Browse branding using DAB',
text: 'DAB',
url: dab_browse
}
}
document.body.addEventListener("yt-navigate-finish", function () {
setupButtons();
});
function setupButtons() {
'use strict';
const row = document.getElementById('center');
row.style.position = 'relative';
const container = document.createElement('div');
container.style.position = 'absolute';
container.style.left = '-200px';
Object.keys(buttons).forEach(k => {
const button = buttons[k]
if (!document.getElementById(`cane-button-${k}`) && button.enabled) {
container.append(createButton(k, button.title, button.text, button.url));
}
})
row.prepend(container);
}
function createButton(id, title, text, url) {
const button = document.createElement('button');
button.id = `cane-button-${id}`;
button.title = title;
button.textContent = text;
button.style.color = '#888888';
button.style.background = '#202020';
button.style.borderStyle = 'solid';
button.style.borderColor = '#303030';
button.style.borderWidth = '1px';
button.style.cursor = 'pointer';
button.onclick = () => {
const v = new URL(document.URL).searchParams.get("v")
if (v) window.open(url + v);
}
return button;
}
@Roki100
Copy link

Roki100 commented Oct 30, 2022

i approve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment