Skip to content

Commit

Permalink
YoutubeVideoInfoAdapter example integration
Browse files Browse the repository at this point in the history
Hacky way, because YoutubeVideoInfoAdapter can't work in synchronous mode
  • Loading branch information
ten4dinosaur authored Nov 2, 2024
1 parent 748192e commit e9d0cdb
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion dist/Simple-YouTube-Age-Restriction-Bypass.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,23 @@
lastPlayerUnlockVideoId = videoId;
lastPlayerUnlockReason = reason;

const unlockedPlayerResponse = getUnlockedPlayerResponse(videoId, reason);
const response = localStorage.getItem('yt_unlocked');
if (response === null) {
if (window.inworkupdate === true) return;
window.inworkupdate = true;
setTimeout(async function() {
localStorage.setItem('yt_unlocked', JSON.stringify(await getYoutubeVideoInfo(videoId, 'web')));
window.location.reload();
}, 0);
return;
}

const unlockedPlayerResponse = JSON.parse(response);
if (unlockedPlayerResponse.responseContext?.mainAppWebResponseContext?.datasyncId) {
if (window.forcePoTokenId !== unlockedPlayerResponse.responseContext.mainAppWebResponseContext.datasyncId)
window.forcePoTokenId = unlockedPlayerResponse.responseContext.mainAppWebResponseContext.datasyncId;
}
localStorage.removeItem('yt_unlocked');

// account proxy error?
if (unlockedPlayerResponse.errorMessage) {
Expand Down

0 comments on commit e9d0cdb

Please sign in to comment.