InstaZoom

Show actual size image when clicking on it. It also unmutes the stories automatically

当前为 2022-06-07 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         InstaZoom
// @namespace    http://www.jeroendekort.nl
// @version      0.15
// @description  Show actual size image when clicking on it. It also unmutes the stories automatically
// @icon         https://cdn.iconscout.com/icon/free/png-256/instagram-53-151118.png
// @author       nljuggler
// @license      MIT
// @match        https://*.instagram.com/*
// @grant        unsafeWindow
// @require      https://code.jquery.com/jquery-2.2.4.js
// ==/UserScript==

$(function(){
  var muteOverride = false;
  addStyleSheet();
  createLightbox();
  $(document).on("click","._si7dy, .FFVAD, .KL4Bh, ._9AhH0, .eLAPa _23QFA,._aagu ._aagw", function() {
    var $divWithImage = $(this).parent().find('img');
    $('body').find('#nljugglerLightbox #lightboxImage').attr('src', $divWithImage.attr('src'));
    $('#nljugglerLightbox').show();

    if ($(this).hasClass("_si7dy")){
      $(this).remove();
    }
    // Remove Instagrams own overlay (if at all displayed),
    // so you don't need to click twice to hide the current image.

    var $imageInTimeline = $(this).closest('._8Rm4L');
    if ($imageInTimeline.length == 0){
        $('[role="dialog"] > div > button.wpO6b').click();
    }
  });

  $('#lightboxImage').click(function() {
    $(this).parent().hide();
    $(this).attr('src', '');
  });

  // Unmute story when muted
  $('body').on('DOMSubtreeModified', '._a3gq', function(){
    if (!muteOverride && $('button[aria-label*="audio"] svg').attr('aria-label').includes('muted'))
     {
       $('button[aria-label*="audio"]').click();
     }
  });

  // (Un)mute by hitting the M key
  $(document).keyup(function(e) {
     if (e.which == 77)
     {
       $('button[aria-label*="audio"]').click();
       muteOverride = true;
     }
  });

  function createLightbox(){
    var lightbox = "<div id='nljugglerLightbox'><img id='lightboxImage'/></div>";
    $('body').append(lightbox);
    $('#nljugglerLightbox').hide();
  }

  function addStyleSheet (){
    addCss('#nljugglerLightbox { position: fixed; top: 10px; left: 40%; width: auto; transform: translateX(-40%); max-height:1000px; z-index:1000; overflow:scroll; border:solid 2px black; }'+
           '#lightboxImage {width: auto; }');
    console.log('InstaZoom styles added');
  }

  function addCss(cssString) {
    var head = document.getElementsByTagName('head')[0];
    var newCss = document.createElement('style');
    newCss.type = "text/css";
    newCss.innerHTML = cssString;
    head.appendChild(newCss);
  }
});