Greasy Fork is available in English.

Show Artist Pixiv ID

Show Pixiv ID of the artist under nickname

// ==UserScript==
// @name        Show Artist Pixiv ID
// @namespace   https://greasyfork.org/en/users/37676
// @description Show Pixiv ID of the artist under nickname
// @match       *://*.pixiv.net/member.php*
// @match       *://*.pixiv.net/member_illust.php*
// @match       *://*.pixiv.net/bookmark.php*
// @match       *://*.pixiv.net/mypixiv_all.php*
// @match       *://*.pixiv.net/stacc/*
// @match       *://*.pixiv.net/*/artworks/*
// @run-at      document-end
// @version     1.0.8
// @grant       none
// @license     Creative Commons Attribution 4.0 International Public License; http://creativecommons.org/licenses/by/4.0/
// ==/UserScript==

var userID = null;
var userName = null;
var userAccount = null;

var preloadMeta = document.querySelector('meta[name="preload-data"]');

if (preloadMeta)
{
	var preloadContent = preloadMeta.getAttribute('content');

    if (preloadContent)
    {
        try
        {
            preloadContent = JSON.parse(preloadContent);
            userID = Object.values(preloadContent.illust)[0].userId;
            userName = Object.values(preloadContent.illust)[0].userName;
            userAccount = Object.values(preloadContent.illust)[0].userAccount;

        } catch(e) {

        }
    }
}

if (userID && userName && userAccount)
{
	var pageObserver = null;
	
    if (!pageObserver)
    {
        pageObserver = new MutationObserver(function(mutations) {

            var profileElement = document.querySelectorAll('a[href*="/users/'+userID+'"]');

            if (profileElement.length > 0)
            {
                for (var i=0; i < profileElement.length; i++)
                {
                    var imageElement = profileElement[i].querySelectorAll('div[role*="img"]');

                    if (imageElement.length > 0)
                    {
                        for (var j=0; j < imageElement.length; j++)
                        {
                            var parentElement = imageElement[j].parentElement;

                            if (parentElement)
                            {
                                var nextElement = parentElement.nextElementSibling;

                                if (nextElement)
                                {
                                    if (nextElement.innerHTML.indexOf(userAccount) < 0)
                                    {
                                        if (parentElement.innerHTML.indexOf(userName) < 0)
										nextElement.innerHTML += '<div>'+userName+'</div>';
										
                                        nextElement.innerHTML += '<div>'+userAccount+'</div>';
                                    }
                                }
                            }
                        }
                    }
                }
            }
        });
		
        pageObserver.observe(document.querySelector('#root'), {
            childList: true,
            subtree: true
        });
    }
}