Flickr- link to all sizes.user.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // ==UserScript==
  2. // @name Flickr: link to all sizes
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-12-17
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://www.flickr.com/photos/*/
  8. // @match https://www.flickr.com/photos/*/page*
  9. // @match https://www.flickr.com/photos/*/with/*
  10. // @match https://www.flickr.com/photos/*/albums/*
  11. // @match https://www.flickr.com/photos/*/albums/*/page*
  12. // @match https://www.flickr.com/photos/*/albums/*/with/*
  13. // @icon https://www.google.com/s2/favicons?sz=64&domain=flickr.com
  14. // @grant none
  15. // ==/UserScript==
  16. (function() {
  17. 'use strict';
  18. const size = '3k';
  19. setTimeout((function monitorUpdateLinks() {
  20. let parent = document.querySelector('#content');
  21. let lastNumberProcessed = 0;
  22. let observer = new MutationObserver(m => {
  23. let links = parent.querySelectorAll('a[href^="/photos"]');
  24. if (links.length == lastNumberProcessed) return;
  25. Array.from(links).forEach(a => {
  26. a.href = updateLink(a.href);
  27. });
  28. });
  29. observer.observe(parent, {
  30. subtree: true,
  31. childList: true,
  32. attributes: true,
  33. });
  34. function updateLink(url) {
  35. if (url.match(/([0-9]?k|[a-z]|comments|page.*)$/))
  36. return url;
  37. let parts = url.match(/\/photos\/[^/]+\/[0-9]+/);
  38. if (!parts)
  39. return url;
  40. console.log('Updating url:', url);
  41. return `${parts[0]}/sizes/${size}`
  42. }
  43. }), 500);
  44. })();