您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Track preordered non-MFC items on collection screen
当前为
- // ==UserScript==
- // @name Add non-MFC figure
- // @namespace https://tharglet.me.uk
- // @version 1.0
- // @description Track preordered non-MFC items on collection screen
- // @author Tharglet
- // @match https://myfigurecollection.net/users.v4.php?*mode=view&*tab=collection&*
- // @grant GM_setValue
- // @grant GM_getValue
- // ==/UserScript==
- (function() {
- 'use strict';
- var additionalFigures = JSON.parse(GM_getValue("additionalFigures", "[]"));
- var drawAdditionalFigures = () => {
- const urlParams = new URLSearchParams(window.location.search);
- const sortType = urlParams.get("sort");
- const output = urlParams.get("output");
- //Clear all additions before redo
- $("#nonMfcAdditions").remove();
- $(".nonMfcIcon").remove();
- $(".nonMfcDelete").remove();
- $(".nonMfcAddedyear").remove();
- if(additionalFigures.length > 0) {
- //Pre-add setup
- const addList = $("#nonMfcFigureList");
- let dateHeadings;
- if(sortType == "groupByReleaseDates") {
- if(output === "0") {
- dateHeadings = $("li.listing-title");
- } else {
- dateHeadings = $(".listing-item h3");
- }
- } else if(sortType.startsWith("groupBy")) {
- if(output === "0") {
- $(".listing-toggles:last").after('<li id="nonMfcAdditions" class="listing-title">Non-MFC</li>');
- } else {
- $(".listing-item .item-icons").prepend('<div class="item-group-by" id="nonMfcAdditions"><h3>Non-MFC</h3></div>');
- }
- }
- //Add icons to page and delete box
- additionalFigures.forEach((fig, idx) => {
- let linkLine;
- const figYear = fig.date.substring(0, 4);
- const figMonth = fig.date.substring(5);
- const figureThumb = `<span class="item-icon nonMfcIcon">
- <a href="${fig.link}" class="tbx-tooltip item-root-0 item-category-1">
- <img src="${fig.image}">
- </a>
- </span>`;
- if(output === "0") {
- linkLine = `<div class='listing-item nonMfcIcon'><div class="stamp item-stamp">
- <a href="/item/872779" class="tbx-tooltip">
- <img class="stamp-icon" src="${fig.image}"</a><div class="stamp-anchor"><a class="tbx-tooltip item-category-1" href="${fig.link}">${fig.name}</a>
- </div></div></div>`
- }
- addList.append(figureThumb + `<a href="#" class='nonMfcDelete' title="Delete" data-index="${idx}"><span class="tiny-icon-only icon-trash-o" data-index="${idx}"></span></a>`);
- let toAppend = true;
- if(sortType == "groupByReleaseDates") {
- dateHeadings.each((idx, heading) => {
- if(toAppend) {
- const headingYear = $(heading).text().substring(0,4);
- const headingMonth = $(heading).text().substring(5);
- if(figYear == headingYear && figMonth == headingMonth) {
- if(output === "0") {
- $(heading).after(linkLine);
- } else {
- $(heading).after(figureThumb);
- }
- toAppend = false;
- } else if(new Date(figYear, figMonth, 1) > new Date(headingYear, headingMonth, 1)) {
- if(output === "0") {
- const newHeading = `<li class="listing-title nonMfcAddedyear" id='nhi_${idx}'>${figYear}-${figMonth}</li></h3>`
- $(heading).before(newHeading + linkLine);
- } else {
- const newHeading = `<h3 class="nonMfcAddedyear" id='nhi_${idx}'>${figYear}-${figMonth}</h3>`
- $(heading).before(newHeading + figureThumb);
- }
- dateHeadings.splice(idx, 0, $(`#nhi_${idx}`));
- toAppend = false;
- }
- }
- });
- } else if(sortType.startsWith("groupBy")) {
- if(output === "0") {
- $("#nonMfcAdditions").after(linkLine)
- } else {
- $("#nonMfcAdditions h3").after(figureThumb);
- }
- } else {
- if(output === "0") {
- $(".listing-toggles:last").after(linkLine);
- } else {
- $(".listing-item .item-icons").prepend(figureThumb);
- }
- }
- });
- $('.nonMfcDelete').click((evt) => {
- evt.preventDefault();
- if(confirm("Delete this figure?")) {
- additionalFigures.splice($(evt.target).attr("data-index"), 1);
- additionalFigures.sort((a, b) => (a.date < b.date) ? 1 : -1);
- GM_setValue("additionalFigures", JSON.stringify(additionalFigures));
- drawAdditionalFigures();
- }
- });
- }
- }
- $().ready(() => {
- const addSection = `<section>
- <h2>Add non-MFC figure</h2>
- <div class='form'>
- <div class='bigchar form-field'>
- <div class='form-label'>Figure name</div>
- <div class='form-input'><input type='text' id='nonMfcItemName'/></div>
- </div>
- <div class='bigchar form-field'>
- <div class='form-label'>Image URL *</div>
- <div class='form-input'><input type='text' id='nonMfcItemImage'/></div>
- </div>
- <div class='bigchar form-field'>
- <div class='form-label'>Item link *</div>
- <div class='form-input'><input type='text' id='nonMfcItemLink'/></div>
- </div>
- <div class='bigchar form-field'>
- <div class='form-label'>Release date (YYYY-MM) *</div>
- <div class='form-input'><input type='text' id='nonMfcItemReleaseDate'/></div>
- </div>
- <div class='form-field'>
- <div class='form-input'>
- <button id='addNonMfcItem'>Add</button>
- </div>
- </div>
- </div>
- </section>
- <section>
- <h2>Added non-MFC figures</h2>
- <div class='form'>
- <div id='nonMfcFigureList' class='item-icons'>
- </div>
- </div>
- </section>`
- $("#side section:last").after(addSection);
- drawAdditionalFigures();
- $("#addNonMfcItem").click((e) => {
- e.preventDefault();
- const name = $("#nonMfcItemName").val() || "Non-MFC figure";
- const image = $("#nonMfcItemImage").val();
- const link = $("#nonMfcItemLink").val();
- const date = $("#nonMfcItemReleaseDate").val();
- if(image && link && date && name) {
- if(date.match(/^\d{4}-0[1-9]|1[0-2]$/)) {
- additionalFigures.push({
- name: name,
- image: image,
- link: link,
- date: date
- });
- additionalFigures.sort((a, b) => (a.date < b.date) ? 1 : -1);
- GM_setValue("additionalFigures", JSON.stringify(additionalFigures));
- drawAdditionalFigures();
- $("#nonMfcItemName").val("");
- $("#nonMfcItemImage").val("");
- $("#nonMfcItemLink").val("");
- $("#nonMfcItemReleaseDate").val("");
- } else {
- alert("Please enter a valid date in YYYY-MM format");
- }
- } else {
- alert("Please fill in all mandatory fields");
- }
- });
- });
- })();