Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed to dynamically ignore incorrect achievement data. #567

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shintaxx
Copy link

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.

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
Copy link

jogerj commented Aug 27, 2024

@shintaxx
Copy link
Author

shintaxx commented Sep 9, 2024

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
Copy link

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
Copy link

jogerj commented Sep 11, 2024

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
Copy link

@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:

  • Built on Chromium with its Overrides function. May work in other browsers with equivalent features.
  • Will work if you set your preferred language/locale first, but will not work after switching languages.
  • I do not yet know what will happen when a new version launches and paimon.moe forces a refresh.
  • There may be console errors if your saved data contains entries for the faulty achievements, but in my experience those console errors do not affect functionality in any way. I personally downloaded my data as JSON, removed the faulty entries, and reuploaded the JSON to avoid such errors.
  • Reminder: this is not the final state of this solution. I imagine that it could become a self-sufficient GreaseMonkey/TamperMonkey script that accesses and modifies the caches without depending on overriding the service worker.

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.
  1. An editor window will open. Editing this file and saving it will save a file to your machine.
  2. 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)
  3. 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;
})());
});
  1. Save the file.
  2. Navigate to the Application tab and select "Service workers" in the side pane.
  3. 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.
  4. In the left pane, choose "Cache storage". There is a cacheimg and a cache, each followed by digits. Choose the non-image entry.
  5. In the main area, find the entry /_app/immutable/pages/achievement/index.svelte-[hash].js and delete it.
  6. 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.
  7. 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 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants