Link to large screenshots on apps.apple.com

19/11/2022, 2:23:02 pm

  1. // ==UserScript==
  2. // @name Link to large screenshots on apps.apple.com
  3. // @namespace Violentmonkey Scripts
  4. // @match https://apps.apple.com/*/app/*
  5. // @grant none
  6. // @version 1.1
  7. // @author -
  8. // @description 19/11/2022, 2:23:02 pm
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12.  
  13. function addLargeScreenshotLinks(){
  14. if(document.querySelector('.large-screenshot-links')) return
  15. Array.from(document.querySelectorAll('div[class*="screenshot"] picture source')).forEach(pic => {
  16. const src = pic.getAttribute('srcset').split(' ').at(-2)
  17. const largeSrc = src.slice(0, src.lastIndexOf('/')) + '/1600x0w.jpg'
  18.  
  19. const aLink = document.createElement('a')
  20. aLink.setAttribute('class', 'large-screenshot-links')
  21. aLink.setAttribute('href', largeSrc)
  22. aLink.setAttribute('target', '_blank')
  23.  
  24. pic.parentNode.insertAdjacentElement('beforebegin', aLink)
  25.  
  26. aLink.appendChild(pic.parentNode)
  27. })
  28. }
  29.  
  30. addLargeScreenshotLinks()
  31.  
  32. // The apps.apple.com site uses html5 history if you click to another app, so re-check about every second.
  33. setInterval(addLargeScreenshotLinks, 800)