Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

250
Vistas
¿Cómo puedo reemplazar el resultado de una búsqueda específica?

El sitio web usa una fetch para obtener un json para su vista de lista (por js empaquetado en la web, por lo que no puedo rediseñarlo);

En el script de tampermonkey, anulo la búsqueda para bloquearlo, modifico su parámetro y vuelvo a buscar así, funciona bien.

 // ==UserScript== // @name not important // @version 0.23 // @namespace none // @match https://www.aaaaaaaaaaaaaa.net/* // ==/UserScript== (function () { unsafeWindow.fetch = (...arg) => { if (arg[0].indexOf('limit=18') > -1) { arg[0] = arg[0].replace('limit=18', 'limit=180'); return fetch(...arg); } else { return fetch(...arg); } } })();

180 es el límite de la API;

Pero no estoy satisfecho, porque 180 no es suficiente, así que ya tenía que encontrar una manera de obtener un json, con el mismo formato pero con resultados de 1800. Ahí está el guión:

 var json = (await (await fetch('https://www.abcdefg.net/ajax/illust/123456789/rec/init?limit=1&lang=zh')).json()); var jsonBody =json.body; var array = [jsonBody.illusts[0].id]; var array2 = jsonBody.nextIds; var combination = array.concat(array2); jsonBody.nextIds = []; jsonBody.illusts= []; var illustComb = []; for(let i = 0; i<5; i++) { var jsonBody = (await (await fetch('https://www.abcdefg.net/ajax/illust/'+ combination[i]+'/rec/init?limit=1&lang=zh')).json()).body; illustComb= illustComb.concat(jsonBody.illusts); } var filtered = []; for(let i = 0; i<illustComb.length; i++) { if(! illustComb[i].isAdContainer == true) filtered.push(illustComb[i]); } jsonBody.illusts=filtered; json.body = jsonBody; return json;

Y quiero secuestrar el json con mi propio json que contiene más resultados.

Pero como la búsqueda, devuelve una Promesa y parece imposible anular una función tan gigantesca; y parece que no es una solicitud de ajax, por lo que no puedo usar algo sobre XMLHttpRequest .

Soy nuevo en Javascript y sé muy poco, por lo que cualquier pista/tutorial/información será muy apreciada y gracias.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

(function () { unsafeWindow.fetch = async (...arg) => { console.log('fetch arg', ...arg); if (arg[0].indexOf('limit=18') > -1) { let illust_id = arg[0].match(/(?<=\/illust\/)\d+/)[0]; arg[0] = arg[0].replace('limit=18', 'limit=180'); var origjs = (await (await fetch('https://www.abcdefg.net/ajax/illust/123456789/rec/init?limit=1&lang=zh')).json()); //omitted, refered to the question. origjs.body = jsonBody; let [resource, config] = arg; let response = await fetch(resource, config); const json = () => response .clone() .json() .then((data) => (data= origjs)); response.json = json; return response; } else { return fetch(...arg); } } })();

referenciado: interceptar solicitudes y respuestas de JavaScript Fetch API

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda