From d98035b8d09691dbbcc7014ea8024784ea398f81 Mon Sep 17 00:00:00 2001 From: sdaqo Date: Sun, 9 Apr 2023 04:48:04 +0200 Subject: [PATCH] add Kwik, use unpacker to improve reliabilty --- src/background.ts | 1 + src/manifest.json | 2 +- src/match/matches.ts | 52 +++++++++++++++++++++++++------------- src/match/unpack.ts | 60 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 18 deletions(-) create mode 100644 src/match/unpack.ts diff --git a/src/background.ts b/src/background.ts index 7858908..78e5145 100644 --- a/src/background.ts +++ b/src/background.ts @@ -2,6 +2,7 @@ import {getMatch} from "./match/match"; import {storageDelete, storageGet, storageSet} from "./store/store"; import {Match} from "./match/matches"; + chrome.webRequest.onBeforeRedirect.addListener(async details => { // check if redirects origins from a previous redirect if (await storageGet('redirect') === undefined) { diff --git a/src/manifest.json b/src/manifest.json index dc6d23d..0b4b949 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -3,7 +3,7 @@ "name": "Stream Bypass", "author": "ByteDream", "description": "A multi-browser addon / extension for multiple streaming providers which redirects directly to the source video.", - "version": "2.1.6", + "version": "2.1.7", "homepage_url": "https://github.com/ByteDream/stream-bypass", "browser_specific_settings": { "gecko": { diff --git a/src/match/matches.ts b/src/match/matches.ts index 32967f5..e5225bd 100644 --- a/src/match/matches.ts +++ b/src/match/matches.ts @@ -1,3 +1,5 @@ +import {unPack} from "./unpack"; + export enum Reliability { HIGH, NORMAL, @@ -71,41 +73,40 @@ class Filemoon implements Match { class Mixdrop implements Match { name = 'Mixdrop' id = 'mixdrop' - reliability = Reliability.NORMAL + reliability = Reliability.HIGH domains = [ 'mixdrop.co', 'mixdrop.to', 'mixdrop.ch', - 'mixdrop.bz' + 'mixdrop.bz', + 'mixdrop.gl' ] - regex = new RegExp(/(?<=\|)\w{2,}/gm) + regex = new RegExp(/eval\(function\(p,a,c,k,e,d\).*?(?=\<\/script\>)/gms) async match(match: RegExpMatchArray): Promise { - const prefix = /(?<=\/\/)[a|s](?=-)/.exec(document.body.innerHTML)[0] - const subdomain = match[1].length < match[2].length ? match[1] : match[2] - const domain = match.slice().sort((a, b) => b.length - a.length).find(m => /^[a-z]+$/.test(m)) - const id = match[1].length > match[2].length ? match[1] : match[2] - const tld = match.find(m => ['net', 'io', 'to', 'sx', 'com'].indexOf(m) !== -1) - const s = match.slice().sort((a, b) => b.length - a.length).slice(1)[0] - const e_t = match.find(m => m.length === 10 && !isNaN(parseInt(m))) + let unpacked = unPack(match[0]) + let url = unpacked.match(/(?<=MDCore.wurl=").*(?=")/)[0] - return `https://${prefix}-${subdomain}.${domain}.${tld}/v/${id}.mp4?s=${s}&e=${e_t}&_t=${e_t}` + return `https:${url}` } } class Mp4Upload implements Match { name = 'Mp4Upload' id = 'mp4upload' - reliability = Reliability.NORMAL + reliability = Reliability.HIGH domains = [ 'mp4upload.com' ] replace = true - regex = new RegExp(/(?<=\|)\w{2,}/gm) + regex = new RegExp(/eval\(function\(p,a,c,k,e,d\).*?(?=\<\/script\>)/gms) async match(match: RegExpMatchArray): Promise { - let id = match.slice().reduce((a, b) => a.length >= b.length ? a : b) - return `https://www4.mp4upload.com:282/d/${id}/video.mp4` + let unpacked = unPack(match[0]) + console.log(unpacked) + let url = unpacked.match(/(?<=player.src\(").*(?=")/)[0] + console.log(url) + return url } } @@ -166,7 +167,7 @@ class Upstream implements Match { domains = [ 'upstream.to' ] - regex = new RegExp(/(?<=\|)\w{2,}/gm) + regex = new RegExp(/(?<=\|)\w{2,}/gms) async match(match: RegExpMatchArray): Promise { return `https://${match[49]}.upstreamcdn.co/hls/${match[148]}/master.m3u8` @@ -215,6 +216,22 @@ class Vupload implements Match { } } +class Kwik implements Match { + name = 'Kwik' + id = 'kwik' + reliability = Reliability.HIGH + domains = [ + 'kwik.cx' + ] + regex = new RegExp(/eval\(function\(p,a,c,k,e,d\).*?(?=\<\/script\>)/gms) + + async match(match: RegExpMatchArray): Promise { + let unpacked = unPack(match[0]) + let url = unpacked.match(/(?<=source=').*(?=')/)[0] + return url + } +} + export const matches = [ new Doodstream(), new Filemoon(), @@ -226,5 +243,6 @@ export const matches = [ new Upstream(), new Vidoza(), new Voe(), - new Vupload() + new Vupload(), + new Kwik() ] diff --git a/src/match/unpack.ts b/src/match/unpack.ts new file mode 100644 index 0000000..44f5351 --- /dev/null +++ b/src/match/unpack.ts @@ -0,0 +1,60 @@ +export const unPack = (packed: String): String => { + // Use eval() for the unPack script because else the `env` variable will not be in scope when the eval in the script is called + const scriptlet = String.raw` + ////////////////////////////////////////// + // Un pack the code from the /packer/ // + // By matthew@matthewfl.com // + // http://matthewfl.com/unPacker.html // + ////////////////////////////////////////// + // version 1.2 + + + (function (code) { + function indent (code) { + try { + var tabs = 0, old=-1, add=''; + for(var i=0;i 0) { + add += "\t"; + old--; + } + old = tabs; + } + + code[i] = add + code[i]; + } + } finally { + tabs = null; + old = null; + add = null; + } + return code; + } + + var env = { + eval: function (c) { + code = c; + }, + window: {}, + document: {} + }; + + eval("with(env) {" + code + "}"); + + code = (code+"").replace(/;/g, ";\n").replace(/{/g, "\n{\n").replace(/}/g, "\n}\n").replace(/\n;\n/g, ";\n").replace(/\n\\n/g, "\n"); + + code = code.split("\n"); + code = indent(code); + + code = code.join("\n"); + return code; + })(${'String.raw`'}` + packed + String.raw`${'`'})` + + return eval(scriptlet); +}