NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Holodex Presence Check // @namespace http://tampermonkey.net/ // @version 1.0.4 // @description Checks whether channels are registered on holodex as you navigate youtube. // @author You // @match https://*.youtube.com/* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @require https://cdnjs.cloudflare.com/ajax/libs/noty/3.1.4/noty.min.js // @resource https://cdnjs.cloudflare.com/ajax/libs/noty/3.1.4/noty.min.css // @grant none // @run-at document-idle // @license MIT // ==/UserScript== var pattern = /^(?:(http|https):\/\/[a-zA-Z-]*\.{0,1}[a-zA-Z-]{3,}\.[a-z]{2,})\/channel\/([a-zA-Z0-9_-]{3,})/; var target = document.getElementsByTagName('head')[0] || document.body || document.documentElement; function initSweetAlert() { var sweetAlert = document.createElement('script'); sweetAlert.type = 'text/javascript'; sweetAlert.src = 'https://cdnjs.cloudflare.com/ajax/libs/noty/3.1.4/noty.min.js'; var sweetAlertCss = document.createElement('link'); sweetAlertCss.href = 'https://cdnjs.cloudflare.com/ajax/libs/noty/3.1.4/noty.min.css' sweetAlertCss.rel = 'stylesheet'; target.appendChild(sweetAlert); target.appendChild(sweetAlertCss); } function initOverride() { //var script = document.createElement('script'); //script.setAttribute('type', 'text/javascript'); //script.text = 'function displayMessage(m){if(m!=null&&m!=""){Noty(m);}};'; //target.appendChild(script); async function gmMain() { 'use strict'; console.log(window.location.href) if (!window.location.href.includes('channel')) return; var matchs = window.location.href.match(pattern); console.log(matchs[2]); if (matchs[2].length !== 'UCYtia5cQdXSWH7GLMWxo9UQ'.length) { new Noty({ theme: 'mint', text: 'It\'s not a proper channel URL:' + window.location.href, type: 'error', timeout: 2000, }).show(); } else { const holodexPresence = await fetch('https://holodex.net/api/v2/channels/' + matchs[2]) const holodexState = await holodexPresence.json(); console.log(holodexState); const url = "https://docs.google.com/forms/d/e/1FAIpQLSennSFS8lLbk9oP4MnkWh-cDQRMhiyHyXEkbRNg_4DMq1CZpw/viewform?usp=pp_url&entry.516201447=I'd+like+to+%E2%9E%95+add+my+channel+to+Holodex.&entry.1443486460=" + window.location.href new Noty({ theme: 'mint', layout: 'topRight', type: holodexState.id ? 'success' : 'warning', //container: '#header.ytd-browse', text: holodexState.id ? 'Holodex contains channel' : 'Holodex does not contain channel. <a href="' + url + '">Click here to propose</a>', timeout: 3000, }).show(); } // Your code here... }; var fireOnHashChangesToo = true; var pageURLCheckTimer = setInterval( function () { if (this.lastPathStr !== location.pathname || this.lastQueryStr !== location.search || (fireOnHashChangesToo && this.lastHashStr !== location.hash) ) { this.lastPathStr = location.pathname; this.lastQueryStr = location.search; this.lastHashStr = location.hash; gmMain(); } }, 111 ); } initSweetAlert(); initOverride(); window.addEventListener("spfdone", function (e) { initOverride() });