Merun's Pixiv artist name fetcher script

Anything shuushuu related that doesn't fit into the other forums :)
User avatar
Yatchen
Posts: 1852
Joined: Sat May 30, 2009 11:43 am
Location: ひみつ

Re: Merun's Pixiv artist name fetcher script

Post by Yatchen » Mon Sep 24, 2012 6:32 pm

OH DANG oops no wonder
;_;
私は悪魔です。

User avatar
Merun
Posts: 2897
Joined: Sat Mar 17, 2007 9:44 am
Location: NoWheRe

Re: Merun's Pixiv artist name fetcher script

Post by Merun » Sat Jul 13, 2013 3:05 pm

Important notice; I have updated the Greasemonkey script, since it was broken. You will need to update it! In the future though, it should update itself automatically :)
Merun @ Twitter

User avatar
Hakuryu
Posts: 251
Joined: Tue Aug 12, 2008 1:50 pm

Re: Merun's Pixiv artist name fetcher script

Post by Hakuryu » Tue Apr 18, 2017 11:43 am

Not sure if it's due to Pixiv's new update or the server the script is hosted on but it seems to be broken for me. ;;
Image

User avatar
Crimson_Camelia
Posts: 576
Joined: Mon Oct 24, 2011 3:23 pm
Location: Poland
Contact:

Re: Merun's Pixiv artist name fetcher script

Post by Crimson_Camelia » Tue Apr 18, 2017 12:34 pm

Oh, I thought I am the only one with this problem. It doesn't work for me since today morning.

User avatar
yong
Posts: 989
Joined: Sat May 03, 2008 8:37 am

Re: Merun's Pixiv artist name fetcher script

Post by yong » Wed Apr 19, 2017 9:37 am

if you all means the romanized artist name does not show on artist avatar below, because pixiv switched to https.
edit the script via your browser extension,
go to line #8, change from:
// @include http://www.pixiv.net/*
to
// @include https://www.pixiv.net/*
save and close.

but this only solve half of the problem :mrgreen:
Image

User avatar
yong
Posts: 989
Joined: Sat May 03, 2008 8:37 am

Re: Merun's Pixiv artist name fetcher script

Post by yong » Wed Apr 19, 2017 9:58 am

replace the script with all the wall of text below, i've only replace http to https so dont worry :mrgreen:
// ==UserScript==
// @name Pixiv Fetcher
// @version 1.2.0
// @copyright Copyright (c) <2011-2013> Merun
// @license MIT http://opensource.org/licenses/MIT
// @namespace http://e-shuushuu.net
// @description Add romanized artist name to Pixiv pages
// @include https://www.pixiv.net/*
// @updateURL https://github.com/RomainLK/pixiv-fetch ... in.user.js
// @grant GM_xmlhttpRequest
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// @require http://ajax.googleapis.com/ajax/libs/jq ... ery.min.js
// ==/UserScript==
/*global GM_xmlhttpRequest: true, GM_getValue: true, GM_setValue: true, GM_deleteValue: true*/
/**
* #getRomanji
* Fetch the romanji from the database
* @param {Number} id id of the Pixiv artist
* @param {Function} callback callback(result)
* */
function getRomanji(a,b){var c=dburl+"artist/"+a;GM_xmlhttpRequest({method:"GET",headers:{Referer:document.URL},url:c,onload:function(a){var c=JSON.parse(a.responseText);null!==c.romanji?b(c.romanji):b(null)}})}/**
* #postLogin
* Login into the database
* @param {String} name username
* @param {String} pass password
* @param {Function} callback callback(err,isLogged)
* */
function postLogin(a,b,c){GM_xmlhttpRequest({method:"POST",url:"http://pixivfetcher-claritism.rhcloud.c ... c(null,!0)}})}/**
* #postRomanji
* Update the artist
* @param {String} value the romanized name
* @param {Function} callback callback(err,isSuccess)
* */
function postRomanji(a,b){GM_xmlhttpRequest({method:"POST",url:"http://pixivfetcher-claritism.rhcloud.c ... b(null,!0)}})}/**
* #Render
* Render the interface on the left
* below the avatar
* @param {Boolean} show By default, false to hide the popup
* */
function render(a){"undefined"!=typeof jDialog&&jDialog.remove(),"undefined"!=typeof p&&p.remove();var b=a||!1,c='<div class="dialog" style="display: none;"><p><strong>Pixiv Fetcher</strong></p><div id="pclose" class="close"></div><form id="pform"><input type="text" name="username" placeholder="Username" style="width:128px;"><br/><br/> <input type="password" name="password" placeholder="Password"> <div id="pnotif"></div><div class="action"><input id="psubmit" type="submit" name="left_column" value="Login" class="button"><input id="pcancel" value="Cancel" class="button remove"></div></form></div>',d='<div class="dialog" style="display: none;"><p><strong>Pixiv Fetcher</strong></p><div id="pclose" class="close"></div><form id="pform"><label for="romanji">Romanji:</label> <input type="text" name="romanji" placeholder="Romanji" style="width:128px;"><div id="pnotif"></div><div class="action"><input id="psubmit" type="submit" name="left_column" value="Submit" class="button"><input id="pcancel" value="Cancel" class="button remove"></div></form><br><br><a href="javascript:void(0)" id="plogout" >Logout</a> </div>';username=GM_getValue("pUsername",null),password=GM_getValue("pPassword",null),// #Rendering when we are not logged
null===username||null===password?(dialog=$.parseHTML(c),jDialog=$(dialog),jDialog.find("#pform").submit(function(){var a=jDialog.find('input[name="username"]').val(),b=jDialog.find('input[name="password"]').val();return postLogin(a,b,function(c,d){d?(GM_setValue("pUsername",a),GM_setValue("pPassword",b),render(!0)):jDialog.find("#pnotif").text(c)}),!1})):(dialog=$.parseHTML(d),jDialog=$(dialog),romanji=romanji||"",jDialog.find('input[name="romanji"]').val(romanji),jDialog.find("#pform").submit(function(){var a=jDialog.find('input[name="romanji"]').val();return postRomanji(a,function(b,c){c?(romanji=a,render(!1)):jDialog.find("#pnotif").text(b)}),!1})),// #Common button binding
jDialog.find("#plogout").click(function(){GM_deleteValue("pUsername"),GM_deleteValue("pPassword"),render(!0)}),jDialog.find(".close").click(function(){jDialog.hide()}),jDialog.find("#pcancel").click(function(){jDialog.hide()}),// #Adding the name under the avatar
p=$("<div>").css({"font-style":"italic","font-size":"13px",cursor:"pointer"}),""===romanji||null===romanji?p.text("No romanji"):p.text(romanji),p.click(function(){jDialog.show()}),user.after(p),p.after(dialog),b&&jDialog.show()}// # Handler for thumbnails view
function getUsers(a){return"http://www.pixiv.net/mypage.php"===docu ... ?$(a).find("#item-container .user"):document.URL.indexOf("http://www.pixiv.net/bookmark.php?type=user")>-1?$(a).find(".userdata a"):document.URL.indexOf("https://www.pixiv.net/bookmark_new_illust.php")>-1?$(a).find(".user"):document.URL.indexOf("http://www.pixiv.net/bookmark.php")>-1?$(a).find(".f10").children():[]}function addRomanjiForEach(a){a.each(function(a,b){b=$(b);var c=b.attr("href").match(/\d+$/g);getRomanji(c,function(a){if(a){var c=$("<div>").text(a).css({"font-style":"italic","font-size":"12px"});b.after(c)}})})}var user=$(".user-link"),id,p,dialog,jDialog,username,password,romanji,dburl="http://pixivfetcher-claritism.rhcloud.com/";// Here we do the first request and first render
user.length>0&&"http://www.pixiv.net/mypage.php"!==document.URL&&(id=user.attr("href").match(/\d+$/g),getRomanji(id,function(a){romanji=a,render(!1)})),//var users;
//users = getUsers(document);
addRomanjiForEach(getUsers(document)),$(document).bind("DOMNodeInserted",function(a){addRomanjiForEach(getUsers(a.target))});
Image

User avatar
Crimson_Camelia
Posts: 576
Joined: Mon Oct 24, 2011 3:23 pm
Location: Poland
Contact:

Re: Merun's Pixiv artist name fetcher script

Post by Crimson_Camelia » Wed Apr 19, 2017 2:59 pm

Thank you, yong!

What does the second half of the problem to solve supposed to be, though? It seems to work as good as before.

User avatar
yong
Posts: 989
Joined: Sat May 03, 2008 8:37 am

Re: Merun's Pixiv artist name fetcher script

Post by yong » Thu Apr 20, 2017 6:33 am

Crimson_Camelia wrote:Thank you, yong!

What does the second half of the problem to solve supposed to be, though? It seems to work as good as before.
first half fix the mismatch pixiv address, so the script will work again.
second half enable back display romanized artist name on new illust page from artist you following.

the script is currently at half working state :mrgreen:
Image

User avatar
yong
Posts: 989
Joined: Sat May 03, 2008 8:37 am

Re: Merun's Pixiv artist name fetcher script

Post by yong » Tue Aug 22, 2017 3:53 pm

Hi all, i've updated the script due to latest ui changes.
I have not optimize the script yet and editing directly on pixiv currently does not work, yet :mrgreen:

Code: Select all

// ==UserScript==
// @name           Pixiv Fetcher
// @version 1.2.0
// @copyright     Copyright (c) <2011-2013> Merun
// @license       MIT http://opensource.org/licenses/MIT
// @namespace     http://e-shuushuu.net
// @description   Add romanized artist name to Pixiv pages
// @include       https://www.pixiv.net/*
// @updateURL     https://github.com/RomainLK/pixiv-fetcher/raw/master/build/pixiv-fetcher.min.user.js
// @grant         GM_xmlhttpRequest 
// @grant         GM_getValue
// @grant         GM_setValue
// @grant         GM_deleteValue
// @require       http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js
// ==/UserScript==
/*global GM_xmlhttpRequest: true, GM_getValue: true, GM_setValue: true, GM_deleteValue: true*/

var user = $('.user-link');
var id;
var p;
var dialog;
var jDialog;
var username;
var password;
var romanji;
var dburl = 'http://pixivfetcher-claritism.rhcloud.com/';
/**
 * #getRomanji
 * Fetch the romanji from the database
 * @param {Number} id id of the Pixiv artist
 * @param {Function} callback callback(result)
 * */
function getRomanji(id, callback) {
	var request = dburl + 'artist/' + id;
	GM_xmlhttpRequest({
		method: 'GET',
		headers: {
			"Referer": document.URL
		},
		url: request,
		onload: function(result) {
			var artist = JSON.parse(result.responseText);
			if (artist.romanji !== null) {
				callback(artist.romanji);
			}
			else {
				callback(null);
			}
		}
	});
}

/**
 * #postLogin
 * Login into the database
 * @param {String} name username
 * @param {String} pass password
 * @param {Function} callback callback(err,isLogged)
 * */
function postLogin(name, pass, callback) {
	GM_xmlhttpRequest({
		method: 'POST',
		url: 'http://pixivfetcher-claritism.rhcloud.com/user/session',
		headers: {
			"Content-type": "application/x-www-form-urlencoded"
		},
		data: 'username=' + name + '&password=' + pass,
		onload: function(result) {
			if (result.status !== 200) {
				callback(result.responseText, false );
			}
			else {
				callback(null, true);
			}
		}
	});
}

/**
 * #postRomanji
 * Update the artist
 * @param {String} value the romanized name
 * @param {Function} callback callback(err,isSuccess)
 * */
 
function postRomanji(value,callback){
				GM_xmlhttpRequest({
				method: 'POST',
				url: 'http://pixivfetcher-claritism.rhcloud.com/artist',
				headers: {
					"Content-type": "application/x-www-form-urlencoded"
				},
				data: 'username=' + username + '&password=' + password + '&pixivId=' + id + '&romanji=' + value,
				onload: function(result) {
					if (result.status !== 200) {
						callback(result.responseText,false);
					}
					else {
						callback(null, true);
					
					}
				}
			});
}

/**
 * #Render
 * Render the interface on the left
 * below the avatar
 * @param {Boolean} show By default, false to hide the popup
 * */
function render(show) {
	if (typeof jDialog !== 'undefined') {
		jDialog.remove();
	}
	if (typeof p !== 'undefined') {
		p.remove();
	}
	var _show = show || false;
	var templateLogin = '<div class="dialog" style="display: none;"><p><strong>Pixiv Fetcher</strong></p><div  id="pclose" class="close"></div><form id="pform">' + '<input type="text" name="username" placeholder="Username" style="width:128px;"><br/><br/> <input type="password" name="password" placeholder="Password"> ' + '<div id="pnotif"></div>' + '<div class="action"><input id="psubmit" type="submit" name="left_column" value="Login" class="button">' + '<input id="pcancel" value="Cancel" class="button remove"></div></form></div>';
	var templateEdit = '<div class="dialog" style="display: none;"><p><strong>Pixiv Fetcher</strong></p><div id="pclose" class="close"></div><form id="pform">' + '<label for="romanji">Romanji:</label> <input type="text" name="romanji" placeholder="Romanji" style="width:128px;">' + '<div id="pnotif"></div>' + '<div class="action"><input id="psubmit"  type="submit" name="left_column" value="Submit" class="button">' + '<input id="pcancel" value="Cancel" class="button remove"></div></form>' + '<br><br><a href="javascript:void(0)" id="plogout" >Logout</a> </div>';

	username = GM_getValue('pUsername', null);
	password = GM_getValue('pPassword', null);
	
	// #Rendering when we are not logged
	if (username === null || password === null) {
		dialog = $.parseHTML(templateLogin);
		jDialog = $(dialog);
		jDialog.find('#pform').submit(function(event) {
			var name = jDialog.find('input[name="username"]').val();
			var pass = jDialog.find('input[name="password"]').val();
			postLogin(name, pass, function(err, isLogged) {
				if (isLogged) {
					GM_setValue('pUsername', name);
					GM_setValue('pPassword', pass);
					render(true);
				}
				else {
					jDialog.find('#pnotif').text(err);
				}
			});
			return false;
		});
	}
	// #Rendering when we are logged
	else {
		dialog = $.parseHTML(templateEdit);
		jDialog = $(dialog);
		romanji = romanji || '';
		jDialog.find('input[name="romanji"]').val(romanji);
		jDialog.find('#pform').submit(function(event) {
			var value = jDialog.find('input[name="romanji"]').val();
			postRomanji(value,function(err,isSuccess){
				if(isSuccess){
						romanji = value;
						render(false);
				}else {
					jDialog.find('#pnotif').text(err);
				}
			});

			return false;
		});
	}
	
	// #Common button binding
	jDialog.find('#plogout').click(function(event) {
		GM_deleteValue('pUsername');
		GM_deleteValue('pPassword');
		render(true);
	});
	jDialog.find('.close').click(function(event) {
		jDialog.hide();
	});
	jDialog.find('#pcancel').click(function(event) {
		jDialog.hide();
	});
	
	// #Adding the name under the avatar
	p = $('<div>').css({
		'font-style': 'italic',
		'font-size': '13px',
		'cursor': 'pointer'
	});
	if (romanji === '' || romanji === null) {
		p.text('No romanji');
	}
	else {
		p.text(romanji);
	}
	p.click(function(event) {
		jDialog.show();
	});
	user.after(p);
	p.after(dialog);
	if (_show) {
		jDialog.show();
	}
}

// Here we do the first request and first render
if (user.length > 0 && document.URL !== 'http://www.pixiv.net/mypage.php') {
	id = user.attr('href').match(/\d+$/g);
	getRomanji(id, function(result){
		romanji = result;
		render(false);
	});
}

// # Handler for thumbnails view 

function getUsers(element){
		if(document.URL === 'https://www.pixiv.net/mypage.php'){
		return $(element).find('#item-container .user');
		}
		else if (document.URL.indexOf('https://www.pixiv.net/member_illust.php?mode=medium') > -1){
		return $(element).find('a.user-name');
		}
		else if (document.URL.indexOf('https://www.pixiv.net/bookmark.php?type=user') > -1){
		return $(element).find('.userdata a');
		}
		else if ( document.URL.indexOf('https://www.pixiv.net/bookmark_new_illust.php') > -1){
		return $(element).find('.user');
		}
		else if (document.URL.indexOf('https://www.pixiv.net/bookmark.php') > -1){
		return $(element).find('.f10').children();
		}
		return [];
}

function addRomanjiForEach(users){
	users.each(function(index,item){
		item = $(item);
		var id = item.attr('href').match(/\d+$/g);
		getRomanji(id,function(result){
			if(result){
				var caption = $('<div>').text(result).css({
					'font-style': 'italic',
					'font-size': '12px',
				});
				
				item.after(caption);
			}
		});
	});
}

//var users;
//users = getUsers(document);

addRomanjiForEach(getUsers(document));

$(document).bind('DOMNodeInserted', function(e) {
	addRomanjiForEach(getUsers(e.target));
});


[/size]
Image

User avatar
Crimson_Camelia
Posts: 576
Joined: Mon Oct 24, 2011 3:23 pm
Location: Poland
Contact:

Re: Merun's Pixiv artist name fetcher script

Post by Crimson_Camelia » Wed Aug 23, 2017 10:34 am

Thank you yong!

Too bad editing on pixiv is not available yet, but your renewed script is already a great help.

User avatar
Merun
Posts: 2897
Joined: Sat Mar 17, 2007 9:44 am
Location: NoWheRe

Re: Merun's Pixiv artist name fetcher script

Post by Merun » Tue Oct 03, 2017 5:01 pm

Boooo, it's me! Back from the dead.

Sadly, I bring you bad news... Openshift 2, the service I'm using to host the server for Pixiv Fetcher is going to be decomissioned on the 5th.


Now now, I'm making backups as I'm typing this. As for the future, I haven't decided yet.
Merun @ Twitter

Post Reply