Inline images on a Niconico News article page

Converts image links on a Niconico News article page to inline images.

  1. // ==UserScript==
  2. // @name Inline images on a Niconico News article page
  3. // @namespace https://akinori.org
  4. // @description Converts image links on a Niconico News article page to inline images.
  5. // @author Akinori MUSHA
  6. // @license 2-clause BSDL
  7. // @include http://news.nicovideo.jp/watch/*
  8. // @version 1.0.0
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. let links = document.querySelectorAll('#MainBody p a[href$=".jpg"]');
  14. for (let i = 0; i < links.length; i++) {
  15. let link = links[i];
  16. if (link.href == link.textContent) {
  17. link.textContent = '';
  18. let img = document.createElement('img');
  19. img.setAttribute('src', link.href);
  20. link.appendChild(img);
  21. }
  22. }
  23. })();