A clever puzzle! I'll break it down step by step, and we'll craft a solution to automate the conversion of your old uBlock Origin filters to the new image-based ones.
The Problem:
Your old filters targeted HTML elements (<a>) with specific href attributes on www.nexusmods.com. The website redesign broke these filters, and now you need to block specific image URLs (https://staticdelivery.nexusmods.com/images/games/4_3/tile_<NUMBER>.jpg) that correspond to those old href values.
The Missing Link:
To connect the old href values to the new image URLs, we need to find the relationship between:
https://www.nexusmods.com/games/<GAMENAME> (old href value)
https://staticdelivery.nexusmods.com/images/games/4_3/tile_<NUMBER>.jpg (new image URL)
The Solution:
We'll use a few tools to automate this process:
- Web Scraping: Extract the game ID (the
<NUMBER> part) associated with each game name from the Nexus Mods website.
- URL manipulation: Construct the new image URL using the extracted game ID.
- Text processing: Transform your old filters into the new image-based filters.
Here's the step-by-step plan:
Tools needed:
- A web browser with Developer Tools (you already have this)
curl (a command-line tool for transferring data; install it if you don't have it: https://curl.se/download.html)
- A text editor (e.g., Notepad++, Sublime Text, or Visual Studio Code)
- A Unix-like environment (e.g., Linux, macOS, or Windows 10 with WSL)
Step 1: Create a list of old filters
Save your old filters in a plain text file, e.g., old_filters.txt:
www.nexusmods.com##[href="https://www.nexusmods.com/games/needforspeedheat"]
www.nexusmods.com##[href="https://www.nexusmods.com/games/needforspeedunbound"]
www.nexusmods.com##[href="https://www.nexusmods.com/games/neverwinter2"]
www.nexusmods.com##[href="https://www.nexusmods.com/games/newvegas"]
www.nexusmods.com##[href="https://www.nexusmods.com/games/nioh2"]
Step 2: Extract game IDs using curl and grep
Create a new file, extract_game_ids.sh (or on Windows), with the following contents: