import { BasePlugin } from '../core/base-plugin.js'; import { __publicField, currentHref, NO, YES } from '../core/constants.js'; class FoldCategoryPlugin extends BasePlugin { getName() { return "FoldCategoryPlugin"; } async initCss() { const settingObj = await storageManager.getSetting(); return `\n \n `; } async handle() { if (window.isListPage && !currentHref.includes("advanced_search")) { this.highlightTag(); utils.loopDetector((() => $("#waitCheckBtn").length), (() => { this.createFoldBtn(); }), 1, 1e4, !0); $("#tags .tag-category .tag-expand").each(((index, el) => { $(el).parent().hasClass("collapse") && el.click(); })); } } highlightTag() { (async () => { const tags = await storageManager.getHighlightedTags(); tags && tags.forEach((text => { $(`#tags a.tag:contains(${text})`).addClass("highlighted"); $(`.tags a.tag:contains(${text})`).addClass("highlighted"); })); })().then(); $("#tags a.tag, .tags a.tag").hover((function() { const $tag = $(this), button = $(''); $tag.append(button); button.fadeIn(0); }), (function() { $(this).find(".highlight-btn").fadeOut(0, (function() { $(this).remove(); })); })); $(document).on("click", ".highlight-btn", (async function(e) { e.stopPropagation(); e.preventDefault(); const $tag = $(this).closest("a.tag"), clonedTag = $tag.clone(); clonedTag.find(".highlight-btn").remove(); const tagText = clonedTag.text().trim().replace(/\s*\(\d+\)$/, ""); let highlightedTags = await storageManager.getHighlightedTags(); if (highlightedTags.includes(tagText)) { highlightedTags = highlightedTags.filter((item => item !== tagText)); $tag.removeClass("highlighted"); } else { highlightedTags.push(tagText); $tag.addClass("highlighted"); } await storageManager.setHighlightedTags(highlightedTags); })); } async createFoldBtn() { const foldCategoryHotKey = await storageManager.getSetting("foldCategoryHotKey"); let $subTags = $("#tags"), checkTagStr = $("#tags dl div.tag.is-info").map((function() { return $(this).text().replaceAll("\n", "").replaceAll(" ", ""); })).get().join(" "); if (!checkTagStr) return; $(".tabs").append(`\n