Something Awful Image-Domain On Hover

Displays the domain of images on hover.

  1. // ==UserScript==
  2. // @name Something Awful Image-Domain On Hover
  3. // @namespace http://www.mathemaniac.org
  4. // @include *://forum.somethingawful.com/showthread.php?*
  5. // @include *://forums.somethingawful.com/showthread.php?*
  6. // @include *://archives.somethingawful.com/showthread.php?*
  7. // @description Displays the domain of images on hover.
  8. // @version 1.1.1
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. // Change for v1.1.1, June 6th, 2016: Support https.
  13. // Change for v1.1.0, December 9th, 2012: Handle attachments.
  14. // Change for v1.0.1, August 6th, 2011: Handle timgs.
  15.  
  16. var imgs = document.getElementsByTagName('img');
  17. for (var i = 0; i < imgs.length; i++) {
  18. var curImg = imgs[i];
  19. if (curImg.classList.contains('img') || curImg.classList.contains('timg')) {
  20. var domain = curImg.getAttribute('src').match(/https?:\/\/([^\/]+)\//);
  21. if (domain) {
  22. curImg.setAttribute('title', domain[1]);
  23. } else {
  24. console.log("SA Image-Domain On Hover: Couldn't determine location of '" + curImg.getAttribute('src') + "'.");
  25. }
  26. } else if (curImg.parentNode.classList.contains('attachment')) {
  27. curImg.setAttribute('title', '[attachment]');
  28. }
  29. }