Steve5451

Revalidate Avatars 1.0.1

Aug 31st, 2016
18,513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Revalidate Avatars
  3. // @version      1.0.1
  4. // @description  Revalidate avatars to see immediate changes.
  5. // @author       Steve5451
  6. // @namespace    http://thepotato.net/
  7. // @include      https://forum.blockland.us/*
  8. // @updateURL    http://pastebin.com/raw/5ya37Eai
  9. // @downloadURL  http://pastebin.com/raw/5ya37Eai
  10. // @grant        none
  11. // @noframes
  12. // ==/UserScript==
  13.  
  14. const avatars = document.getElementsByClassName("avatar"); // Get all avatars on the page
  15.  
  16. for(var i = 0; i < avatars.length; ++i) { // For every avatar
  17.     const src = avatars[i].src; // Get image url
  18.  
  19.     if(!src || !src.startsWith("https://forum.blockland.us")) continue; // Skip altered or blank avatars
  20.  
  21.     let xml = new XMLHttpRequest(); // Open new http request
  22.     xml.open("HEAD", src, true); // We only need the header, no need to fetch the whole image
  23.     xml.setRequestHeader("Cache-Control", "max-age=0"); // Set image to expire so it's revalidated
  24.     xml.send();
  25. }
  26.  
  27. /* Changelog:
  28.  
  29. 1.0   - Initial release
  30. 1.0.1 - Compatibility patch
  31.  
  32. */
Advertisement
Add Comment
Please, Sign In to add comment