Skip to content

Instantly share code, notes, and snippets.

@monodyle
Forked from J2TEAM/youtube-playlist-maker.js
Created March 23, 2018 08:08
Show Gist options
  • Save monodyle/f8e474cca7f16e53f0c341f8353070d6 to your computer and use it in GitHub Desktop.
Save monodyle/f8e474cca7f16e53f0c341f8353070d6 to your computer and use it in GitHub Desktop.
Code thêm nhiều video Youtube vào một playlist.
/* Developed by Juno_okyo */
(function(e, b) {
function f(a, b) {
var d = fetch,
e = "sej=" + encodeURIComponent(JSON.stringify({
playlistEditEndpoint: {
playlistId: a,
actions: [{
addedVideoId: b,
action: "ACTION_ADD_VIDEO"
}]
},
clickTrackingParams: "juno_okyo_j2team_community",
commandMetadata: {
webCommandMetadata: {
url: "/service_ajax",
sendPost: !0
}
}
})) + "&session_token=",
f = encodeURIComponent;
var c = /"XSRF_TOKEN":"([^"]+)"/.exec(document.head.innerHTML);
c = null !== c ? c[1] : !1;
return d("https://www.youtube.com/service_ajax?name=playlistEditEndpoint", {
method: "POST",
credentials: "same-origin",
headers: {
"content-type": "application/x-www-form-urlencoded"
},
body: e + f(c)
})
}
function d() {
var a = b.pop();
a = (new URL(a)).searchParams.get("v");
f(e, a).then(function(a) {
0 < b.length && setTimeout(d, 500)
})
}
d()
})('YOUR_PLAYLIST_ID', 'YOUR_VIDEO_URLS_IN_ARRAY');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment