From 99d40a5a068b8736b64ba7d437e1aa7aa987b941 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Mon, 31 Oct 2022 20:47:45 +1100 Subject: Disable webrtc preload plugin --- assets/preload-plugins/webrtc.js | 74 ---------------------------------------- assets/webrtc.js | 74 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 74 deletions(-) delete mode 100644 assets/preload-plugins/webrtc.js create mode 100644 assets/webrtc.js diff --git a/assets/preload-plugins/webrtc.js b/assets/preload-plugins/webrtc.js deleted file mode 100644 index 1acd443a..00000000 --- a/assets/preload-plugins/webrtc.js +++ /dev/null @@ -1,74 +0,0 @@ -(this.webpackChunkdiscord_app = this.webpackChunkdiscord_app || []).push([ - [[228974]], - { - 632540: (module, exports, req) => { - window.find = (filter, options = {}) => { - const { cacheOnly = false } = options; - for (let i in req.c) { - if (req.c.hasOwnProperty(i)) { - let m = req.c[i].exports; - if (m && m.__esModule && m.default && filter(m.default)) return m.default; - if (m && filter(m)) return m; - } - } - if (cacheOnly) { - console.warn("Cannot find loaded module in cache"); - return null; - } - console.warn("Cannot find loaded module in cache. Loading all modules may have unexpected side effects"); - for (let i = 0; i < req.m.length; ++i) { - let m = req(i); - if (m && m.__esModule && m.default && filter(m.default)) return m.default; - if (m && filter(m)) return m; - } - console.warn("Cannot find module"); - return null; - }; - window.findByUniqueProperties = (propNames, options) => - find((module) => propNames.every((prop) => module[prop] !== undefined), options); - window.findByDisplayName = (displayName, options) => find((module) => module.displayName === displayName, options); - window.req = req; - - init(); - } - }, - (t) => t(632540) -]); - -function retry(callback) { - return new Promise((resolve) => { - const interval = setInterval(() => { - const mod = callback(); - if (!mod) return; - - clearInterval(interval); - resolve(mod); - }, 50); - }); -} - -async function init() { - const SDP = await retry(() => findByUniqueProperties(["truncateSDP"])); - const StringManipulator = findByUniqueProperties(["uniq"]); - - const truncateSDP = SDP.truncateSDP; - SDP.truncateSDP = (e) => { - const result = truncateSDP(e); - const i = result.codecs.find((x) => x.name === "VP8"); - const a = new RegExp("^a=ice|a=extmap|opus|VP8|fingerprint|" + i?.rtxPayloadType + " rtx", "i"); - return { - sdp: StringManipulator(e) - .split(/\r\n/) - .filter(function (e) { - return a.test(e); - }) - .uniq() - .join("\n"), - codecs: result.codecs - }; - }; - // SDP.generateUnifiedSessionDescription = (e) => { - // console.log(e); - // return new RTCSessionDescription({ sdp: e.baseSDP.replace(/sendonly/g, "recvonly"), type: "answer" }); - // }; -} \ No newline at end of file diff --git a/assets/webrtc.js b/assets/webrtc.js new file mode 100644 index 00000000..1acd443a --- /dev/null +++ b/assets/webrtc.js @@ -0,0 +1,74 @@ +(this.webpackChunkdiscord_app = this.webpackChunkdiscord_app || []).push([ + [[228974]], + { + 632540: (module, exports, req) => { + window.find = (filter, options = {}) => { + const { cacheOnly = false } = options; + for (let i in req.c) { + if (req.c.hasOwnProperty(i)) { + let m = req.c[i].exports; + if (m && m.__esModule && m.default && filter(m.default)) return m.default; + if (m && filter(m)) return m; + } + } + if (cacheOnly) { + console.warn("Cannot find loaded module in cache"); + return null; + } + console.warn("Cannot find loaded module in cache. Loading all modules may have unexpected side effects"); + for (let i = 0; i < req.m.length; ++i) { + let m = req(i); + if (m && m.__esModule && m.default && filter(m.default)) return m.default; + if (m && filter(m)) return m; + } + console.warn("Cannot find module"); + return null; + }; + window.findByUniqueProperties = (propNames, options) => + find((module) => propNames.every((prop) => module[prop] !== undefined), options); + window.findByDisplayName = (displayName, options) => find((module) => module.displayName === displayName, options); + window.req = req; + + init(); + } + }, + (t) => t(632540) +]); + +function retry(callback) { + return new Promise((resolve) => { + const interval = setInterval(() => { + const mod = callback(); + if (!mod) return; + + clearInterval(interval); + resolve(mod); + }, 50); + }); +} + +async function init() { + const SDP = await retry(() => findByUniqueProperties(["truncateSDP"])); + const StringManipulator = findByUniqueProperties(["uniq"]); + + const truncateSDP = SDP.truncateSDP; + SDP.truncateSDP = (e) => { + const result = truncateSDP(e); + const i = result.codecs.find((x) => x.name === "VP8"); + const a = new RegExp("^a=ice|a=extmap|opus|VP8|fingerprint|" + i?.rtxPayloadType + " rtx", "i"); + return { + sdp: StringManipulator(e) + .split(/\r\n/) + .filter(function (e) { + return a.test(e); + }) + .uniq() + .join("\n"), + codecs: result.codecs + }; + }; + // SDP.generateUnifiedSessionDescription = (e) => { + // console.log(e); + // return new RTCSessionDescription({ sdp: e.baseSDP.replace(/sendonly/g, "recvonly"), type: "answer" }); + // }; +} \ No newline at end of file -- cgit 1.5.1