Link to large screenshots on apps.apple.com

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Link to large screenshots on apps.apple.com
// @namespace   Violentmonkey Scripts
// @match       https://apps.apple.com/*/app/*
// @grant       none
// @version     1.1
// @author      -
// @description 19/11/2022, 2:23:02 pm
// @license MIT
// ==/UserScript==


function addLargeScreenshotLinks(){
  if(document.querySelector('.large-screenshot-links')) return
  Array.from(document.querySelectorAll('div[class*="screenshot"] picture source')).forEach(pic => {
    const src = pic.getAttribute('srcset').split(' ').at(-2)
    const largeSrc = src.slice(0, src.lastIndexOf('/')) + '/1600x0w.jpg'

    const aLink = document.createElement('a')
    aLink.setAttribute('class', 'large-screenshot-links')
    aLink.setAttribute('href', largeSrc)
    aLink.setAttribute('target', '_blank')

    pic.parentNode.insertAdjacentElement('beforebegin', aLink)

    aLink.appendChild(pic.parentNode)
  })
}

addLargeScreenshotLinks()

// The apps.apple.com site uses html5 history if you click to another app, so re-check about every second.
setInterval(addLargeScreenshotLinks, 800)