NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Community Playlist Generator // @namespace Violentmonkey Scripts // @include https://redacted.ch/forums.php?action=viewthread&threadid=50337* // @grant none // @version 0.2 // @author nastykast // @copyright 2021, nastykast (https://openuserjs.org/users/nastykast) // @license MIT // @description 6/3/2021, 11:05:15 AM // ==/UserScript== (function() { 'use strict'; var posts = document.querySelectorAll('.forum_post, .forum-post'); for (var i = 0; i < posts.length; i++) { var p = posts[i]; if (p.getAttribute('class').indexOf('preview_wrap') != -1) { continue; } if (p.id == 'reply_box') { continue; } var post_header_links = p.getElementsByTagName('td')[0].firstElementChild; var button = document.createElement('a'); button.href = 'javascript:void(0);'; button.innerHTML = 'Generate playlist'; button.setAttribute('class', 'brackets'); button.addEventListener('click', generate.bind(undefined, p), false); post_header_links.appendChild(document.createTextNode(' - ')); post_header_links.appendChild(button); } })(); function generate(postTable) { var links = postTable.getElementsByTagName('a'); var ids = []; for (var i = 0; i < links.length; i++) { var id = ''; if (links[i].href.includes("youtube")) { var pieces = links[i].href.split("?"); if (pieces.length > 1) { var params = pieces[1].split("&"); for (var j = 0; j < params.length; j++) { if (params[j].startsWith("v=")) { id = params[j].substring(2); } } } } else if (links[i].href.includes("youtu.be")) { id = links[i].href.split("/").pop(); } if (id) { ids.push(id); } } var playlist = 'https://youtube.com/watch_videos?video_ids=' + ids.join(); window.open(playlist, '_blank'); }