Stackoverflow: Fix broken images

Script to replace just links (which should be images instead) with `img` tags for properly representation

  1. // ==UserScript==
  2. // @name Stackoverflow: Fix broken images
  3. // @description Script to replace just links (which should be images instead) with `img` tags for properly representation
  4. // @version 0.2.0
  5. // @namespace ClasherKasten
  6. // @grant none
  7. // @license MIT
  8. // @include https://stackoverflow.com/questions/*
  9. // ==/UserScript==
  10.  
  11. const links = document.querySelectorAll('a[href^="https://i.stack.imgur.com/"]');
  12. links.forEach(link => {
  13. const img = document.createElement('img');
  14. img.src = link.href;
  15. img.alt = link.innerText;
  16. link.innerText = '';
  17. link.appendChild(img);
  18. });