samliew / SO-mod-userscripts

Stack Overflow Moderation Userscripts
MIT License
124 stars 33 forks source link

CircuitLab simulate circuit links get intercepted by Lightbox Images #174

Closed catija closed 1 year ago

catija commented 1 year ago

Describe the bug Lightbox Images (which is super awesome and I recommend it all the time, by the way) seems to use the image URL as a way to identify what to convert into an image. Unfortunately, there's a tool on Electrical Engineering that actually creates schematic links using a stack.imgur image as part of the URL, which seems to cause Lightbox to try and render it as an image, which then fails with a "The requested content cannot be loaded. Please try again later." message. And, once the message is displayed, the X to close the image no longer works, so you have to refresh the page to make it clear (though I'm guessing that not trying to display the image will fix this?).

To Reproduce Steps to reproduce the behaviour:

  1. Go to a post on EE with a schematic. e.g. (with Lightbox Images enabled)
  2. Click on "simulate this circuit" under one of the CircuitLab images
  3. See error

Expected behaviour Instead of attempting to show an image, Lightbox should not try to display these links as images and clicking should actually take me to the CircuitLab viewer (https://www.circuitlab.com/editor/#?id=dstej3q4rw83). The link URLs look like this: https://electronics.stackexchange.com/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fAoB3Q.png so maybe you can add an if statement to look for URLs that contain "plugins/schematics" or something like that?

Screenshots If applicable, add screenshots to help explain your problem. Screenshot 2023-08-07 at 8 37 26 AM Screenshot 2023-08-07 at 8 37 38 AM

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

samliew commented 1 year ago

I assume such links will always end with .png. Done.