Skip to content

Instantly share code, notes, and snippets.

View ten4dinosaur's full-sized avatar

ten4dinosaur

View GitHub Profile
// ==UserScript==
// @name YoutubeVideoInfoAdapter
// @namespace http://tampermonkey.net/
// @version 0.1
// @description YoutubeVideoInfoAdapter
// @author You
// @grant GM_xmlhttpRequest
// @grant GM.xmlHttpRequest
// @connect www.youtube.com
// @connect googlevideo.com
(function () {
const root = typeof unsafeWindow !== "undefined" ? unsafeWindow : window;
let tokenId = undefined;
let updateFunction = undefined;
Object.defineProperty(root, "forcePoTokenId", {
get: () => tokenId,
set: (value) => {
tokenId = value;
if (typeof updateFunction === "function") updateFunction();
const unrestrictedSanitizer = (string) => string;
const unrestrictedPolicy = window.trustedTypes.createPolicy("po#html", {
createHTML: unrestrictedSanitizer,
createScript: unrestrictedSanitizer,
createScriptURL: unrestrictedSanitizer,
});
const poRequest = async (endpoint, content) => {
const response = await fetch(
`https://jnn-pa.googleapis.com/$rpc/google.internal.waa.v1.Waa/${endpoint}`,