sebaro / savetube Goto Github PK
View Code? Open in Web Editor NEWDownload videos from video sharing web sites.
Home Page: http://sebaro.pro/savetube
License: GNU General Public License v3.0
Download videos from video sharing web sites.
Home Page: http://sebaro.pro/savetube
License: GNU General Public License v3.0
Hi,
This evening, the Savetube script (2022.07.11) stopped working on Youtube for Firefox
Digging in the console, we get:
Uncaught (in promise) SyntaxError: unterminated regular expression literal
ytGetUnscrambleParamFunc moz-extension://437a936d-5257-43bf-a2f7-372a6e0a7b5b/userscripts/SaveTube.user.js?id=5095000f-66d1-4199-ade0-8aace8f6b18a:799
SaveTube moz-extension://437a936d-5257-43bf-a2f7-372a6e0a7b5b/userscripts/SaveTube.user.js?id=5095000f-66d1-4199-ade0-8aace8f6b18a:919
window["__f__ljqiosax.rql"]/</< moz-extension://437a936d-5257-43bf-a2f7-372a6e0a7b5b/userscripts/SaveTube.user.js?id=5095000f-66d1-4199-ade0-8aace8f6b18a:1308
window["__f__ljqiosax.rql"]/< moz-extension://437a936d-5257-43bf-a2f7-372a6e0a7b5b/userscripts/SaveTube.user.js?id=5095000f-66d1-4199-ade0-8aace8f6b18a:1322
St https://www.youtube.com/watch?v=ZU74ATbAhns:9
window["__f__ljqiosax.rql"]/< moz-extension://437a936d-5257-43bf-a2f7-372a6e0a7b5b/userscripts/SaveTube.user.js?id=5095000f-66d1-4199-ade0-8aace8f6b18a:1
"__f__ljqiosax.rql" moz-extension://437a936d-5257-43bf-a2f7-372a6e0a7b5b/userscripts/SaveTube.user.js?id=5095000f-66d1-4199-ade0-8aace8f6b18a:1
St https://www.youtube.com/watch?v=ZU74ATbAhns:9
s https://www.youtube.com/watch?v=ZU74ATbAhns:72
<anonymous> https://www.youtube.com/watch?v=ZU74ATbAhns:75
g https://www.youtube.com/watch?v=ZU74ATbAhns:69
The erroneous line at 799 is
ytMainFuncBody = 'try {' + ytMainFuncBody + '} catch(e) {return null}';
Adding some console logs, it seems the body of the parsed ytMainFuncBody function is:
var b=a.split(""),c=[-265090265,751968325,-1951798130,160288705,function(d,e,f,h,l,m,n,p){return e(f,h,l,m,n,p)},
1941204574,/()\/"()(;)[;,'
which looks indeed truncated
From the original script https://www.youtube.com/s/player/1dda5629/player_ias.vflset/fr_FR/base.js we see a regex /()\/"()(;)[;,'};]();/
which holds a dandling "}", that probably breaks the parser
As a quick and dirty fix, I made the "parseMyContent" function as below:
function parseMyContent(content, pattern) {
var parse, response;
content = content.replace(/(\r\n|\n|\r)/gm, '');
content = content.replace("/()\\/\"()(;)[;,'};]();/","/####/"); // Manual dirty patch
parse = content.match(pattern);
if (parse) {
response = (/g$/.test(pattern)) ? parse : parse[1];
response = response.replace("/####/", "/()\\/\"()(;)[;,'};]();/"); // Manual dirty patch
}
return response;
}
By replacing the regex with dandling "}" before running the parsing Regex of line 797 ( ytMainFuncBody = getMyContent(ytScriptUrl, new RegExp('(?:^|;)' + ytMainFuncName.replace(/\$/, '\\$') + '\\s*=\\s*function\\s*' + '\\s*\\(\\w+\\)\\s*\\{(.*?)\\};'));
) I get a properly parsed youtube script and SaveTube works again
I'm not opening a pull request here, because this is clearly not a nice "fix", but I wanted to share my root cause analysis of this issue so you may find a proper fix quicker and easier :)
(Note: since I edited this parseMyContent, i'm not 100% of my line numbers in this issue)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.