HF Group Image "OG"

Reduces group images

  1. // ==UserScript==
  2. // @name HF Group Image "OG"
  3. // @version 1.2
  4. // @description Reduces group images
  5. // @author gloom
  6. // @match https://hackforums.net/*
  7. // @license MIT
  8. // @namespace http://tampermonkey.net/
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Function to resize group images
  15. function resizeGroupImages() {
  16. // Find all images that have a src containing 'images/groupimages'
  17. const groupImages = document.querySelectorAll('img[src*="images/groupimages"]');
  18.  
  19. groupImages.forEach(img => {
  20. // Get current dimensions from width/height attributes
  21. let currentWidth = parseInt(img.getAttribute('width'));
  22. let currentHeight = parseInt(img.getAttribute('height'));
  23.  
  24. // Sets the new dimensions
  25. if (!isNaN(currentWidth) && !isNaN(currentHeight)) {
  26. const newWidth = currentWidth - 40;
  27. const newHeight = currentHeight - 15;
  28.  
  29. img.setAttribute('width', newWidth);
  30. img.setAttribute('height', newHeight);
  31. // Also set style to ensure it takes effect
  32. img.style.width = newWidth + 'px';
  33. img.style.height = newHeight + 'px';
  34. }
  35. });
  36. }
  37.  
  38. // Runs when page loads
  39. window.addEventListener('load', resizeGroupImages);
  40.  
  41. // Run for dynamically loaded images
  42. const observer = new MutationObserver(resizeGroupImages);
  43. observer.observe(document.body, {
  44. childList: true,
  45. subtree: true
  46. });
  47. })();