Mitemin_Image_Code

Mitemin Image to Narou Tag

Pada tanggal 17 Maret 2015. Lihat %(latest_version_link).

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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();
			}
		}
	);

})();