There is such code:
let parsedUrl = new URL("https://streamguard.cc/serial/412c6a4100be1a0f41a4c57b00c2d57d/iframe?season=1&nocontrols=1&episode=366?origin=yummyanime.com"); // ?...?... console.log(parsedUrl.searchParams.get("episode") ); // wparam="366?origin=yummyanime.com" TODO: param="366" I get the URL through window.location.href, and at the top of the URL as an example.
How to do without the split method?
parsedUrl.searchParams.get("episode").split("?"); // Array [ "366", "origin=yummyanime.com" ];
I think it would be wrong to break it this way and probably need to separate the lines before the get method. Ideally, the result of such a "parsed URL" would be written to an array.
// Array [ "season=1&nocontrols=1&episode=366", "origin=yummyanime.com" ]
Support for MS browsers is not needed.
After some time, I wrote this:
let parsedUrl = new URL(window.location.href); parsedUrl.href.split("?").map(function(echo){ return new URLSearchParams(echo).get("episode"); });//Array [ null, "366", null ] Will such a decision? Maybe there is a more elegant and clear solution? I apologize for the style of the former with ++ 'shnik :) I would only be on pure JS , if possible, and the output is "s = 1 & e = 366".
With url.match (/ episode = (\ d +) /) [1], you will need to use the try..catch construction.
A pair of //Array["1","366"] fit in, as a result, it is planned to write to the database. Or you can get the output in the format string "s =" + data + "& e =" + data ("s = 1 & e = 366").