GithubHelp home page GithubHelp logo

sebaro / savetube Goto Github PK

View Code? Open in Web Editor NEW
13.0 13.0 2.0 3.33 MB

Download videos from video sharing web sites.

Home Page: http://sebaro.pro/savetube

License: GNU General Public License v3.0

JavaScript 99.54% Shell 0.22% Batchfile 0.24%

savetube's People

Contributors

sebaro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

54m4d derajared85

savetube's Issues

Dirty fix for broken Youtube this evening

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.