Mitemin_Image_Code

Mitemin Image to Narou Tag

Versione datata 17/03/2015. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name        Mitemin_Image_Code
// @namespace   phodra
// @description Mitemin Image to Narou Tag
// @include     http://*.mitemin.net/userpageimagesearch/search
// @include     http://*.mitemin.net/i*
// @version     0.1
// @grant       none
// ==/UserScript==

(function (){

	// 小説本文用のタグを生成
	var TagToNovel = function( userid, imageid)
	{
		return "<" + imageid + "|" + userid + ">";
	}
	// 活動報告用のタグを生成
	var TagToBlog = function( userid, imageid)
	{
		return "<img src='http://"+userid+".mitemin.net/userpageimage/viewimage/icode/"+imageid+"/' width='520px' alt='"+imageid+"' />"
	}

	var AppendCode = function()
	{
		
		// 画像一覧
		var $sbox = $(".search_box");
		if( $sbox.size() )
		{
			var $div = $("<div style='margin-bottom:10px' />");
			var $txb = $("<input type='text' onfocus='this.select();' readonly='readonly' name='url'>");
			var userid = $(".profile_name>p:eq(1)").text().match(/\d+/);
			for( var i=0; i<$sbox.size(); i++)
			{
				var $item = $sbox.eq(i);
				if( $item.children("div.codetag").size() ) continue;
				
				var imgid = $item.children("a").attr('href').match(/i\d+/);
				var $codetag = $("<div class='codetag'>");
				$item.append($codetag);
				
				var $toNovel = $div.clone();
				$toNovel.text("小説:");
				var $toNovel_textbox = $txb.clone();
				$toNovel_textbox.attr( 'value', TagToNovel(userid,imgid));
				$codetag.append($toNovel);
				$toNovel.append($toNovel_textbox);
				
				var $toBlog = $div.clone();
				$toBlog.text("活報:");
				var $toBlog_textbox = $txb.clone();
				$toBlog_textbox.attr( 'value', TagToBlog(userid,imgid));
				$codetag.append($toBlog);
				$toBlog.append($toBlog_textbox);
			}
		}

		// 個別画像ページ
		if( $(".imageview").size() )
		{
			var $input = $(".image_infomation:last td input");
			var $parent = $input.parent();
			$input.css('width','230px');

			var thisurl_val = $input.eq(0).attr('value');
			var userid = thisurl_val.match(/\d+/);
			var imgid = thisurl_val.match(/i\d+/);

			var $box = $("<div class='urlbox'>");
			var $div = $("<div style='margin-bottom:10px' />");
			
			var $thisurl = $div.clone();
			$thisurl.text("この画像の URL:");
			$thisurl.append($input.eq(0));
			$box.append($thisurl);
			
			var $tburl = $div.clone();
			$tburl.text("Track Back URL:");
			$tburl.append($input.eq(1));
			$box.append($tburl);

			var $noveltag = $div.clone();
			$noveltag.text("小説本文用タグ:");
			var $noveltag_textbox = $input.eq(0).clone();
			$noveltag_textbox.attr('value', TagToNovel(userid,imgid));
			$noveltag.append($noveltag_textbox);
			$box.append($noveltag);
			
			var $blogtag = $div.clone();
			$blogtag.text("活動報告用タグ:");
			var $blogtag_textbox = $input.eq(0).clone();
			$blogtag_textbox.attr('value', TagToBlog(userid,imgid));
			$blogtag.append($blogtag_textbox);
			$box.append($blogtag);

			$parent.parent().append($box);
			$parent.hide();
			
		}
	}

	AppendCode();
	$(document).on(
		{
//			'GM_AutoPagerizeLoaded': function(){
//			},
			'GM_AutoPagerizeNextPageLoaded': function(e){
				AppendCode();
			}
		}
	);

})();