4chan Archive Image Expander

Adds inline image expansion to 4chan archives.

2017-10-24 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name           4chan Archive Image Expander
// @description    Adds inline image expansion to 4chan archives.
// @author         Hen Tie
// @homepage       http://hen-tie.tumblr.com/
// @namespace      https://greasyfork.org/en/users/8336
// @include        /https?:\/\/(desuarchive.org|archived.moe)\/.*\/thread\/.*/
// @grant          none
// @require        http://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js
//// @icon           URL
// @version        1.0
// ==/UserScript==
$(function(){
	//video settings
	var settings = 'loop autoplay controls';
	//prevent weird wrapping around expanded images
	$('.theme_default .post header').css('display','inline-block');
	$('.thread_image_box a').on('click', function(e){
		var myHref = $(this).attr('href');
		//new elements containing full size href as src
		var img = $('<img />').attr({'src':myHref, 'class':'openItem'});
		var webm = $('<video ' + settings + '><source type="video/webm" src="' + myHref + '"/></video>').attr('class','openItem').css({'max-width':'100%','height':'auto'});
		//check filetype, hide thumbnail, insert full size file
		if (myHref.match(/.gif$|.png$|.jpg$/g)) {
			e.preventDefault();
			$(this).css('display','none');
			$(this).after(img);
		} else if (myHref.match(/.webm$/g)) {
			e.preventDefault();
			$(this).css('display','none');
			$(this).after(webm);
		} else {
			console.log('"4chan Archive Image Expander"\nUnsupported filetype, please report.\nSee @homepage or @namespace for contact info.');
		}
	});
	//on reclick, remove full size, show thumbnail
	$(document).on('click', 'video.openItem', function(e){
		$(this).prev().css('display','inline-block');
		$(this).remove();
	});
});