YJM local patch for Zetrr Instagram sorter
Date: 2026-06-20

Purpose:
- Restore personal-use Instagram popularity sorting when the original extension stops collecting items.

Main changes:
1) instagram/script_instagram.js
   - Added fetch() hook for /graphql/query responses.
   - Original code only intercepted XMLHttpRequest. If Instagram loads profile/reels data through fetch(), sorting never receives items.
   - Added deep search for these GraphQL connection keys:
     - xdt_api__v1__feed__user_timeline_graphql_connection
     - xdt_api__v1__clips__user__connection_v2

2) instagram/init_zettr_instagram.js
   - Made active tab detection more tolerant.
   - Original code assumed [aria-selected="true"] always had href. Instagram DOM changes can make that fail.

How to test:
1) Unzip this file.
2) Open chrome://extensions
3) Turn on Developer mode.
4) Load unpacked extension and select the unzipped folder containing manifest.json.
5) Open an Instagram profile page.
6) Try Sort by Likes / Comments on Posts, or Sort by Views on the Reels tab.
7) Open DevTools Console and check for:
   [Zetrr yjm patch] fetch hook installed

Known limits:
- This still depends on Instagram's private web GraphQL response shape.
- If Instagram changes the connection keys or blocks/rate-limits requests, additional patching is required.
- This is for personal testing/use only, not redistribution.
