MadeBaruna / paimon-moe

Your best Genshin Impact companion! Help you plan what to farm with ascension calculator and database. Also track your progress with todo and wish counter.
https://paimon.moe
MIT License
1.41k stars 270 forks source link

Fixed to dynamically ignore incorrect achievement data. #567

Open shintaxx opened 5 months ago

shintaxx commented 5 months ago

Added a function to ignore extraneous data included in the JSON data. The JSON data is expected to be mechanically generated, so modifying the JSON data itself was considered inappropriate.

jogerj commented 2 months ago

Related issues #485 #487 #488 #491 #493 #497 #498 #500 #504 #513 #517 #524 #532 #537 #538 #539 #540 #552 #557 #558 #560 #565 #580 #581

Related PRs #566 #551 #533

shintaxx commented 2 months ago

I fully understand that my points on this issue are duplicative. On top of that, the moderators continue to ignore it, so I am going out of my way to propose a new approach. I question why you continue to ignore all these points. I suspect there is malice in that. Some of the other proposed fixes are to modify the original data, the JSON file, but please understand that my approach is to look at the ID and ignore it, so there is no need to update the JSON every time there is an update.

In any case, if you are not willing to take this issue seriously, I will not use this site again. Goodbye.

inoffensive commented 2 months ago

I'm seconding what @shintaxx has mentioned. While I understand that we're not in the position to demand anything because we're not paying to use the site, it's a bit disheartening to see these still up. It's close to a year since they were noticed. Why haven't they been fixed?

The site so behind on so many relevant elements... Spincrystals haven't been updated. Furniture sets haven't been updated. TCG cards haven't been updated. I'm better off assuming it's dead...

jogerj commented 2 months ago

I just triage stuff around here. It's up to @MadeBaruna to apply and merge fixes. The Discord server community is pretty active (despite its lawlessness) and community run alternatives are routinely discussed/under development (check out dval.in)

ivanjonas commented 1 month ago

@shintaxx @inoffensive I'm one of those who has been driven mad by this, too. I finally have the beginnings of a solution that does not depend on source code modifications by leveraging Chromium's "local overrides" feature to modify the service worker. I'd like to share in case you have the bandwidth to complete it.

Discaimers:

Steps:

  1. Navigate to a non-Achievement page and open dev tools.
  2. In the Sources pane, in the Page side-pane, scroll to the bottom and find service-worker.js. Right-click it and choose Override Content
    • You may need to do some one-time setup such as picking a local directory in which to save your files.
  3. An editor window will open. Editing this file and saving it will save a file to your machine.
  4. In the same side-pane where Page was, select Overrides and ensure that "Enable Local Overrides" is checked. (This is only temporary, as you'll see later)
  5. In the service-worker.js editor, replace the eventlistener at the bottom with the following code. The modified section is marked.

    self.addEventListener("fetch", async (e) => {
    e.request.url.indexOf(self.location.origin) !== 0 || e.request.method !== "GET" || e.respondWith((async () => {
    const a = e.request.url.indexOf(f) === 0 ? r : n, c = await caches.open(a), t = await c.match(e.request);
    if (t)
      return t;
    // START of modification
    // const s = await fetch(e.request);
    let s = await fetch(e.request);
    
    if (e.request.url.startsWith("https://paimon.moe/_app/immutable/pages/achievement/index.svelte-")) {
      const body = await s.text();
      const newBody = body.replaceAll(/\{id:(?:81416|81418|81426|81429|81451|81453),name:"[^"]+",desc:"[^"]+",reward:\d+,ver:"[^"]+"},?/g, "");
      const newResponse = new Response(newBody, { headers: { 'Content-Type': 'application/javascript' } } );
      s = newResponse;
    }
    
    // END of modification
    return s.ok && c.put(e.request, s.clone()), s;
    })());
    });
  6. Save the file.
  7. Navigate to the Application tab and select "Service workers" in the side pane.
  8. Click "Unregister" in the main area. This will remove the service worker from the browser's cache. Next time paimon.moe loads, the service worker will be re-installed, but it'll be your modified version! And it'll be cached, so every future page reload will use your modified service worker code.
  9. In the left pane, choose "Cache storage". There is a cacheimg and a cache, each followed by digits. Choose the non-image entry.
  10. In the main area, find the entry /_app/immutable/pages/achievement/index.svelte-[hash].js and delete it.
  11. Now simply reload the page (still at a non-Achievements URL) and click to navigate to Achievements. The reload will install and cache your modified service-worker.js, and the navigation will use the new service worker to modify the large JSON object containing the faulty achievements.
  12. If you wish, you may now turn off Local Overrides.

Let me know how it goes or if you encounter any problems. I'll probably be more responsive than Baruna 👍