Commit bc832a6e authored by sebaro's avatar sebaro

Fix YouTube

parent 274fef93
......@@ -3,6 +3,9 @@
/* SaveTube Changelog */
#2020.10.31
- fixes YouTube
#2020.10.15
- fixes VIKI
......
......@@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "SaveTube",
"version": "2020.5.10",
"version": "2020.10.31",
"description": "Download videos from video sharing web sites.",
......
// ==UserScript==
// @name SaveTube
// @version 2020.05.10
// @version 2020.10.31
// @description Download videos from video sharing web sites.
// @author sebaro
// @namespace http://sebaro.pro/savetube
......@@ -1010,8 +1010,8 @@ function SaveTube() {
var ytVideoList = {};
if (ytVideosContent) {
if (ytVideosContent.match(/^s=/) || ytVideosContent.match(/&s=/) || ytVideosContent.match(/,s=/) || ytVideosContent.match(/u0026s=/)) {
var ytScriptURL = getMyContent(page.url, '"js":\\s*"(.*?)"', true);
if (!ytScriptURL) ytScriptURL = getMyContent(page.url.replace(/watch.*?v=/, 'embed/').replace(/&.*$/, ''), '"js":\\s*"(.*?)"', true);
var ytScriptURL = getMyContent(page.url, '"js(?:Url)?":\\s*"(.*?)"', true);
if (!ytScriptURL) ytScriptURL = getMyContent(page.url.replace(/watch.*?v=/, 'embed/').replace(/&.*$/, ''), '"js(?:Url)?":\\s*"(.*?)"', true);
if (ytScriptURL) {
ytScriptURL = page.win.location.protocol + '//' + page.win.location.hostname + ytScriptURL;
ytScriptSrc = getMyContent(ytScriptURL, 'TEXT', false);
......@@ -1372,26 +1372,25 @@ function SaveTube() {
try {
if (localStorage.getItem(SHA1Key)) {
SHA1FuncBody = localStorage.getItem(SHA1Key);
if (SHA1FuncBody.indexOf('SHA-1') == -1) throw false;
}
else throw false;
}
catch(e) {
SHA1FuncBody = getMyContent('https://raw.githack.com/Caligatio/jsSHA/master/src/sha1.js', 'TEXT', false);
SHA1FuncBody = getMyContent('https://raw.githack.com/Caligatio/jsSHA/master/dist/sha1.js', 'TEXT', false);
localStorage.setItem(SHA1Key, SHA1FuncBody);
}
var SHA1Func = new Function('a', SHA1FuncBody);
var SHA1 = new SHA1Func();
if (SHA1.jsSHA) {
var shaObj = new SHA1.jsSHA("SHA-1", "TEXT");
var vkTimestamp = parseInt(Date.now() / 1000);
var vkQuery = "/v5/videos/" + vkVideoID + "/streams.json?app=100005a&t=" + vkTimestamp + "&site=www.viki.com"
var vkToken = "MM_d*yP@`&1@]@!AVrXf_o-HVEnoTnm$O-ti4[G~$JDI/Dc-&piU&z&5.;:}95\=Iad";
shaObj.setHMACKey(vkToken, "TEXT");
shaObj.update(vkQuery);
var vkSig = shaObj.getHMAC("HEX");
var vkSource = "https://api.viki.io" + vkQuery + "&sig=" + vkSig;
vkVideosContent = getMyContent(vkSource, 'TEXT', false);
}
var shaObj = (SHA1.jsSHA) ? new SHA1.jsSHA("SHA-1", "TEXT") : new jsSHA("SHA-1", "TEXT");
var vkTimestamp = parseInt(Date.now() / 1000);
var vkQuery = "/v5/videos/" + vkVideoID + "/streams.json?app=100005a&t=" + vkTimestamp + "&site=www.viki.com"
var vkToken = "MM_d*yP@`&1@]@!AVrXf_o-HVEnoTnm$O-ti4[G~$JDI/Dc-&piU&z&5.;:}95\=Iad";
shaObj.setHMACKey(vkToken, "TEXT");
shaObj.update(vkQuery);
var vkSig = shaObj.getHMAC("HEX");
var vkSource = "https://api.viki.io" + vkQuery + "&sig=" + vkSig;
vkVideosContent = getMyContent(vkSource, 'TEXT', false);
}
/* Get Videos */
......
// ==UserScript==
// @name SaveTube
// @version 2020.10.15
// @version 2020.10.31
// @description Download videos from video sharing web sites.
// @author sebaro
// @namespace http://sebaro.pro/savetube
......@@ -1010,8 +1010,8 @@ function SaveTube() {
var ytVideoList = {};
if (ytVideosContent) {
if (ytVideosContent.match(/^s=/) || ytVideosContent.match(/&s=/) || ytVideosContent.match(/,s=/) || ytVideosContent.match(/u0026s=/)) {
var ytScriptURL = getMyContent(page.url, '"js":\\s*"(.*?)"', true);
if (!ytScriptURL) ytScriptURL = getMyContent(page.url.replace(/watch.*?v=/, 'embed/').replace(/&.*$/, ''), '"js":\\s*"(.*?)"', true);
var ytScriptURL = getMyContent(page.url, '"js(?:Url)?":\\s*"(.*?)"', true);
if (!ytScriptURL) ytScriptURL = getMyContent(page.url.replace(/watch.*?v=/, 'embed/').replace(/&.*$/, ''), '"js(?:Url)?":\\s*"(.*?)"', true);
if (ytScriptURL) {
ytScriptURL = page.win.location.protocol + '//' + page.win.location.hostname + ytScriptURL;
ytScriptSrc = getMyContent(ytScriptURL, 'TEXT', false);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment