From 8d99f12fc6bcd3e40d8c457ccf2f4b0da3a4a1ee Mon Sep 17 00:00:00 2001 From: NotAProton Date: Fri, 1 Dec 2023 08:33:38 +0530 Subject: [PATCH] add crowdNavigate helper function --- src/bypasses/tii.js | 6 +++--- src/helpers/dom.js | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/bypasses/tii.js b/src/bypasses/tii.js index f289952ab..9a4302f2c 100644 --- a/src/bypasses/tii.js +++ b/src/bypasses/tii.js @@ -9,12 +9,12 @@ export default class TiiLa extends BypassDefinition { execute() { const urlObj = new URL(window.location.href) this.helpers.crowdQuery('tii.la', urlObj.pathname.slice(1)).then((dest) => { - this.helpers.crowdNavigate(dest); + this.helpers.crowdNavigate(dest) }); /*keep checking for the button*/ - setInterval(() => { + setInterval(() => { const button = document.querySelector("a.btn.btn-success.btn-lg.get-link"); - if (button.href) { + if (button && button.href) { this.helpers.crowdContribute('tii.la', urlObj.pathname.slice(1), button.href) this.helpers.safelyNavigate(button.href) } diff --git a/src/helpers/dom.js b/src/helpers/dom.js index 98be5e92e..3ec577953 100644 --- a/src/helpers/dom.js +++ b/src/helpers/dom.js @@ -247,7 +247,7 @@ export function crowdQuery(domain, path) { return new Promise((resolve, reject) => { const timeout = setTimeout(() => { reject(new Error('Timeout: crowd response not received')); - }, 5000); //5 sec timeout + }, 10000); //10 sec timeout document.addEventListener('ff53054c0e13_crowdResponse', function (event) { clearTimeout(timeout); @@ -443,6 +443,13 @@ export async function bypassRequests(execution_method) { return Promise.resolve(result); }; } +/** + * Navigates to the specified URL. To be used for crowd sourced bypasses. + * @param {string} target - The target URL to navigate to. + */ +export function crowdNavigate(target) { + unsafelyNavigate(target, null, true); +} export default { insertInfoBox, @@ -451,6 +458,7 @@ export default { ffclipboard, crowdQuery, crowdContribute, + crowdNavigate, followAndContribute, unsafelyNavigate, parseTarget,