Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save syoichi/1913412 to your computer and use it in GitHub Desktop.
Save syoichi/1913412 to your computer and use it in GitHub Desktop.
ポストに含まれている全ての外部にある画像でクリックイベントを発生させている為に、外部にある画像が偶数個の場合に画像が拡大されない不具合を修正した。また、Textポストの「+ Upload photo」によって貼りつけたインライン画像の拡大にも対応させた。
// ==UserScript==
// @id Tumblr Dashboard Expand Inline Images
// @name Tumblr Dashboard Expand Inline Images
// @namespace http://saitamanodoruji.tumblr.com/
// @author saitamanodoruji
// @version 0.0.2
// @update 2012-02-26T14:32:25.242Z(GMT+09:00)
// @description expand inline images of post in Dashboard.
// @include http://www.tumblr.com/dashboard*
// @include http://www.tumblr.com/show/*
// @include http://www.tumblr.com/likes*
// @include http://www.tumblr.com/liked/by/*
// @include http://www.tumblr.com/tagged*
// @include http://www.tumblr.com/blog*
// @exclude http://www.tumblr.com/dashboard/iframe*
// @run-at document-end
// @priority 0
// @compatibility Firefox 10.0.2(Scriptish 0.1.7), Chrome 17.0.963.56, Safari 5.1.2(NinjaKit 0.8.5), Opera 11.61 on Windows 7 Home Premium SP1 64bit
// @charset UTF-8
// ==/UserScript==
/*jslint browser: true, maxerr: 50, maxlen: 80, indent: 4*/
// Edition 2012-02-23
(function executeExpandInlineImages(doc) {
'use strict';
var evt, clickInlineImages;
if (!doc.getElementsByClassName('post_content').length) {
return;
}
evt = doc.createEvent('MouseEvent');
evt.initMouseEvent(
'click',
true,
true,
window,
0,
0,
0,
0,
0,
false,
false,
false,
false,
0,
null
);
clickInlineImages = function clickInlineImages(arg) {
var target, firstInlineImages, firstInlineImagesLen;
target = arg.target || arg;
if (!(/^post_/.test(target.id) || target === doc)) {
return;
}
firstInlineImages = doc.evaluate(
'.//' +
'div[contains(concat(" ", @class, " "), " post_content ")]/' +
'descendant::img[' +
'@external_src or ' +
'contains(concat(" ", @class, " "), " toggle_inline_image ")' +
'][1]',
target,
null,
7,
null
);
firstInlineImagesLen = firstInlineImages.snapshotLength;
while (firstInlineImagesLen) {
firstInlineImages
.snapshotItem(firstInlineImagesLen -= 1)
.dispatchEvent(evt);
}
};
clickInlineImages(doc);
doc.addEventListener('DOMNodeInserted', clickInlineImages);
}(document));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment