54ac / stream-detector

A Firefox addon for keeping track of manifests used by various streaming protocols and downloading media files.
https://addons.mozilla.org/en-US/firefox/addon/hls-stream-detector/
Mozilla Public License 2.0
642 stars 96 forks source link

SyntaxError: nothing to repeat #153

Closed mortyobnoxious closed 2 years ago

mortyobnoxious commented 2 years ago

I have a user-defined command like this: %url%#\%tabtitle%;%referer%;%origin%

When I click filename to copy with user-defined command above. image

I got this error on the console after the update: image

54ac commented 2 years ago

Works fine for me and I don't think anything has changed in the copying portion of the script in a while. Can you share where this occurs?

mortyobnoxious commented 2 years ago

I think it has something to do with my regex: (Watch Free ?| ?Full Movies Online HD ?| ?İzle ?\/ ?.+ İzle| ?İzle)

After removing parenthesis, it worked. Like this: Watch Free ?| ?Full Movies Online HD ?| ?İzle ?\/ ?.+ İzle| ?İzle

Sorry for the inconvenience.

But now, my regex doesn't work.

mortyobnoxious commented 2 years ago

I tested regex, there seems to be no problem: image

Can't use this with the extension.

54ac commented 2 years ago

Yeah, I think the regex parser in the addon messes up with slashes and parentheses maybe. Weird that it broke now since there were no changes to the regex code since then. I'll see if anything can be done.

mortyobnoxious commented 2 years ago

I lost my regex setting after the update and tried to create the same one as before but I think I also messed it up.

I removed backslash and slash (\/). Use it like this without a problem. /Watch Free ?| ?Full Movies Online HD ?| ?İzle ?/gi

54ac commented 2 years ago

Yeah it's the slashes. In the next version I'll just parse it as is without trying to detect groups (just the string without //gi).

54ac commented 2 years ago

I've simplified regex parsing in v2.10.15 to minimize further problems. Let me know if it works fine for you now as a string.

mortyobnoxious commented 2 years ago

I don't know if the mistake is on my end but it stills gives an error like this: image

regex is this: ?İzle ?_ ?.+ İzle

and I also tried with this: ?İzle ?\/ ?.+ İzle

This was working before, now this is not working, too: ?- NBA, MMA, UFC, Boxing, NFL Sports HD Streams - Weakstreams|Watch Free ?| ?Full Movies Online HD ?| ?İzle ?|Happening now_ ?|_|Watch ?| ?full HD on 1movieshd.com Free| ?Live Streams

54ac commented 2 years ago

In that case I've no clue why it breaks. Might be an issue with the regex itself, but I know next to nothing about regular expressions, so I'm of no help in that regard. I might add some validator to the options to make things a bit clearer.

mortyobnoxious commented 2 years ago
var code = "https://abc.abcdefg.com/hls2/04/00008/abcdef/master.m3u8?t=abcdef&s=abcdef&e=abc&f=abc&srv=ss1&pp=abcd&i=0.0&sp=0#\Prisoners of the Ghostland İzle _ Hayalet Ülkenin Tutsakları İzle;https://abc.abcdefg.com/embed-abc.html;https://abc.abcdefg.com/embed-abc.html"

var regexCommand = " ?İzle ?_ ?.+ İzle"

var regexReplace = ""

code = code.replace(new RegExp(regexCommand, ""), regexReplace || "");
console.log(code);

I get this from extensions popup.js file, added variables myself and tried it on console. It works without a problem. I don't know what is the problem.

54ac commented 2 years ago

I don't know what is the problem.

It's the space in your regexCommand string. ? tests for the previous token in the string, therefore it works because the space is there.

mortyobnoxious commented 2 years ago

Actually that space was always there but Github trims it if i put it in code and start with space.

If i put that regex (with space, just like js code above) on the extension, it doesn't work but it works on the console.

54ac commented 2 years ago

That's because all trailing spaces at the beginning and end of input fields get trimmed. I'll have to add an exception for that.

mortyobnoxious commented 2 years ago

Sorry I misunderstood you above. I didn't know it was getting trimmed. Yeah, I think that's the problem. When I remove that space from the variable on the console, it gives the same error because there's nothing preceding the ?.

On the extension I edited my regex (removed trailing spaces and quantifier(?)), it works without a problem.

mortyobnoxious commented 2 years ago

@rowrawer By the way can you put global flag to regex code = code.replace(new RegExp(regexCommand, "g"), regexReplace || "");

or put an option for global and case insensitive flags to options page.

54ac commented 2 years ago

I can't really be bothered to add even more options but I've already added the global flag to the command, it'll be available in the next version.