tumblr img enlarger

Replace images in tumblr post with 1280px version if exists

目前為 2016-05-28 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        tumblr img enlarger
// @namespace   tie
// @include     http://*.tumblr.com/post/*
// @include     https://*.tumblr.com/post/*
// @version     0.3.1
// @grant       none
//@require      http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @description Replace images in tumblr post with 1280px version if exists
// ==/UserScript==
var $;
// Add jQuery
(function () {
  if (typeof unsafeWindow.jQuery == 'undefined') {
    var GM_Head = document.getElementsByTagName('head') [0] || document.documentElement,
    GM_JQ = document.createElement('script');
    GM_JQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js';
    GM_JQ.type = 'text/javascript';
    GM_JQ.async = true;
    GM_Head.insertBefore(GM_JQ, GM_Head.firstChild);
  }
  GM_wait();
}) ();
// Check if jQuery's loaded
function GM_wait() {
  if (typeof unsafeWindow.jQuery == 'undefined') {
    window.setTimeout(GM_wait, 100);
  } else {
    $ = unsafeWindow.jQuery.noConflict(true);
    letsJQuery();
  }
}// All your GM code must be inside this function

function letsJQuery() {
  /*begin*/
  $('img').each(function () {
    var src1 = $(this).attr('src');
    var img = $(this);
    img.removeAttr('class');
    img.off('click');
    img.parent().off("click", "**");
    var width1 = img.width();
    if (src1.indexOf('_500') != - 1)
    {
      //alert('500 found at '+src1);
      var src2 = src1.replace(/_500/g, '_1280');
      //alert("new url "+ src2);
      /*replace with big image url*/
      img.attr('src', src2);
      img.width(width1);
    }
    var wrap = img.parent();
    if (wrap.is('a')) {
    img.unwrap();
    }
    img.wrap('<a href=\'' + img.attr('src') + '\' target=\'_blank\' id=\'ioioi\'></a>');
    //img.insertAfter('<a href=\'' + img.attr('src') + '\' target=\'_blank\' id=\'ioioi\'>link</a>');
    //img.parent().off("click", "**");
  });
  /*end*/
}