kemono.su links for ppixiv

Add kemono.su patreon & fanbox & fantia links into ppixiv

< Feedback on kemono.su links for ppixiv

Question/comment

§
Posted: 17.12.2023

Thanks for the great script, I have a digression,

Please tell me how to Add "phixiv.net" buttons on ppixiv user dropdown and turn it into a convenient menu as shown in your script. Phixiv is a function that parses Pixiv URLs. I often use phixiv in DISCORD chat, so I am tired of adding h letters by myself.
https://github.com/HazelTheWitch/phixiv

I have also suggested a similar function to the ppixiv author. Here I would also like to ask you how to add a new phixiv dropdown button.

EnergoStalinAuthor
§
Posted: 18.12.2023
Edited: 18.12.2023

Look at this. Whole discussion is here.

interface Url {
  url: URL | string
  icon: string // Can use material icons
  // Any string for preventing duplicates
  // it also setting some default icons based on this property
  type: string
  label: string // Displayed title
}

And when you need retrigger user update call this.

function notifyUserUpdated(userId) {
  unsafeWindow.ppixiv.userCache.callUserModifiedCallbacks(userId);
}

You can get user id from userInfo.userId

That's pretty much everything you need to know.

And i guess we need to patch ppixiv code a bit to allow multiple event callabcks cause for now it's only one function. So either we merge support for it into ppixiv itsef or use closures as workaround which can be buggy i think.

EnergoStalinAuthor
§
Posted: 18.12.2023

And since it's not undesirable feature you can try merge it upstream instead of separate userscript as well.

Because in case of separate userscript i guess we still need to patch ppixiv code a bit to allow multiple event callabcks cause for now it's only one function. So either we merge support for it into ppixiv itself or use closures as workaround which can be potentially buggy i think.

§
Posted: 19.12.2023

Thanks for the response, I thought I would just put some paragraphs that follow the same pattern and add code,
but it didn't work because I can't write code, so I gave up.


    const cachedPatreonUsers = {};
    const cachedRedirects = {};
    const labelMatchingMap = {
//        "patreon": "patreon.com",
//        "fanbox": "Fanbox",
//        "fantia": "fantia.jp",
        "pixiv": "pixiv.net",
    };




//    }
// 
//    function fanbox(extraLinks, userInfo) {
//        extraLinks.push({
//            url: new URL(`https://kemono.su/fanbox/user/${userInfo.userId}`),
//            icon: "mat:money_off",
//            type: "kemono_fanbox",
//            label: "Kemono fanbox"
//        });
//    }
// 
//    function fantia(link, extraLinks) {
//        //const id = link.url.toString().split("/").pop();
//        extraLinks.push({
//            url: new URL(`https://kemono.su/fantia/user/${id}`),
//            icon: "mat:money_off",
//            type: "kemono_fantia",
//            label: "Kemono fantia"
        });

    function Pixiv(link, extraLinks) {
        const id = link.url.toString().split("/").pop();
        extraLinks.push({
            url: new URL(`https://www.phixiv.net/user/${id}`),
            icon: "mat:money_off",
            type: "phixiv_pixiv",
            label: "phixiv pixiv"
        });

    }







    function addUserLinks({ extraLinks, userInfo }) {
        for(const link of [...extraLinks, ...getLinksFromDescription(extraLinks)]) {
            switch(link.label) {
//                case "Fanbox": fanbox(extraLinks, userInfo); break;
//                case "patreon.com": patreon(link, extraLinks, userInfo); break;
//                case "fantia.jp": fantia(link, extraLinks); break;
                case "pixiv.net": pixiv(link, extraLinks); break;
            }
        }

EnergoStalinAuthor
§
Posted: 19.12.2023

Nah forget you can get illustration info like this but for adding link to this list access to internal MenuOptionButton class needed if you don't want copy paste code from ppixiv into your script or using bundler what will tree shake it from ppixiv code into your script automatically.

So the most adequate option is to make changes into ppixiv itself or partially bundle widgets module if it should stay in separate userscript form.

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      2023-12-19
// @description  try to take over the world!
// @author       You
// @match        https://*.pixiv.net/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=pixiv.net
// @run-at       document-idle
// @grant        none
// @unwrap
// ==/UserScript==

(function() {
    'use strict';

    function dropdownMenuOptions({ moreOptionsDropdown }) {
        const { mediaInfo } = moreOptionsDropdown
        if(!mediaInfo) return

        const page = window.location.hash.split("=").pop()
        const { illustId } = mediaInfo

        if(page === "#ppixiv") console.log("No page. Context menu opened from listing page")
        console.log(illustId, page)
    }

    window.vviewHooks = {
        ...window.vviewHooks,
        dropdownMenuOptions
    }
})();
§
Posted: 20.12.2023

thank you for your explanation.

Post reply

Sign in to post a reply.