Shows all the screenshots without the scrollbox and adds direct links for fullsized versions
目前為
// ==UserScript==
// @name GooglePlay direct screenshot links
// @description Shows all the screenshots without the scrollbox and adds direct links for fullsized versions
// @include https://play.google.com/store*
// @version 1.0.9
// @author wOxxOm
// @namespace wOxxOm.scripts
// @license MIT License
// @run-at document-start
// ==/UserScript==
const GALLERY_ATTR = 'data-slideable-portion-heuristic-width';
const GALLERY_SELECTOR = `[${GALLERY_ATTR}]`;
onMutation([{
addedNodes: [document.body],
target: document.documentElement,
}]);
new MutationObserver(onMutation)
.observe(document, {subtree:true, childList:true});
function onMutation(mutations) {
for (const m of mutations) {
let node = m.target;
if (!node.hasAttribute(GALLERY_ATTR)) {
for (let i = 0; node; (node = m.addedNodes[i++])) {
if (node.localName === 'c-wiz' || node.getElementsByTagName('c-wiz')[0]) {
node = node.querySelector(GALLERY_SELECTOR);
if (node)
break;
}
}
}
if (node) {
requestAnimationFrame(() => {
node.outerHTML = '<div>' + [...node.getElementsByTagName('img')].map(makeImageHtml) + '</div>';
});
break;
}
}
}
function makeImageHtml(img) {
const src = img.dataset.src || (img.srcset || '').split(' ', 1)[0] || img.src || '';
return img.nextElementSibling
? img.parentNode.outerHTML
: `<a href="${src.replace(/=.*/, '=h900')}"><img src="${src.replace(/=.*/, '=h420')}"></a>`;
}