GooglePlay direct screenshot links

Shows all the screenshots without the scrollbox and adds direct links for fullsized versions

目前為 2017-09-13 提交的版本,檢視 最新版本

// ==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.5
// @author        wOxxOm
// @namespace     wOxxOm.scripts
// @license       MIT License
// @run-at        document-start
// ==/UserScript==

var style;

new MutationObserver(function(mutations, observer) {
  if (!style || !style.parentElement) {
    style = (document.head || document.documentElement).appendChild(document.createElement('style'));
    style.textContent = '\
      .expand-pages-container,\
      .details-section.screenshots .thumbnails-wrapper,\
      .details-section.screenshots .thumbnails {\
          overflow-x: visible !important;\
          white-space: normal !important;\
          height: auto !important;\
      }\
      .expandable .expand-button,\
      .expand-pages-container .expand-page {\
          display: none !important;\
      }\
      .expand-pages-container .expand-page:first-child {\
          display: block !important;\
      }\
      .details-section.screenshots .thumbnails,\
      .details-section.screenshots .thumbnails-wrapper {\
          margin-bottom: 0 !important;\
      }\
    ';
  }
  for (var i=0, ml=mutations.length, m; (i<ml) && (m=mutations[i]); i++)
    if (!m.target.previousElementSibling && (m.target.className == 'details-section-body expandable'))
      for (var j=0, nodes=m.addedNodes, nl=nodes.length, n; (j<nl) && (n=nodes[j]); j++)
        if (n.nodeType == 1 && n.children[0]) {
          if (!n.querySelector('img.screenshot.clickable'))
            return;
          var title = document.querySelector('.document-title').textContent.trim();
          var imgs = n.querySelectorAll(':not(a) > img.screenshot.clickable');
          for (var k=0, img; (k<imgs.length) && (img=imgs[k]); k++)
            img.outerHTML = '<a href="' + img.src.replace(/^(.+?)=h\d+.*/,'$1=h900') +
                             '" title="' + title + ' (' + (k+1) + ')">' + img.outerHTML + '</a>';
          return;
        }
}).observe(document, {subtree:true, childList:true});