AO3: [Wrangling] Show Fandom Touch Date!

Show last date you entered the wrangle page for a fandom!

当前为 2023-06-14 提交的版本,查看 最新版本

// ==UserScript==
// @name         AO3: [Wrangling] Show Fandom Touch Date!
// @description  Show last date you entered the wrangle page for a fandom!
// @version      1.0.0

// @author       daydreamorama
// @namespace    N/A
// @license      MIT license

// @match        *://*.archiveofourown.org/tag_wranglers/*
// @match        *://*.archiveofourown.org/tags/*/wrangle*
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_openInTab
// ==/UserScript==

(function($) {

    // set this to true if you want in first column, note if you are using other scripts
    // and you set this to true you'll probably have to modify them to call: split("\n")[0]
    // when they try to get the fandom name from the table
    const USE_IN_FIRST_COLUMN = false

    'use strict';

    // which page is this?
    var page_url = window.location.pathname;

    // wrangle page!
    if (page_url.includes("/wrangle")) {
        const fandomName = $("h2.heading a").text();
        const key = fandomName + "_clickedDate";

        console.log("Have key: " + key);

        const new_value = new Date().toLocaleString();
        console.log("Saving new date: " + new_value + " on " + key);
        GM_setValue(key, new_value);
    }
    else { // its the page of all the fandoms!
        const array = f => Array.prototype.slice.call(f, 0)

        //gets all the fandoms
        const currentfandoms = array(document.getElementsByTagName("th"))

        const rows = array($("tr"))

        var firstRow = true
        for (const row of rows) {
            if (firstRow) {
                if (!USE_IN_FIRST_COLUMN) {
                    row.append("Last Looked At");
                }
                firstRow = false;
                continue;
            }
            const fandomheader = row.getElementsByTagName("th")[0];
            const fandomName = fandomheader.innerText
            const key = fandomName + "_clickedDate";
            //console.log("KEY: " + key + "fandom: " + fandomName)

            //If the fandomheader's info hasn't been saved by the user before, we will set the old value as 0
            const savedDate = GM_getValue(key) || 0;

            // this will neatly sidestep the fact that the table headers also end up here but they'll be 0  always!
            if (savedDate != 0) {
                //console.log("date: " + savedDate.toLocaleString())

                // originally I wanted as part of the header cell but then other scripts that used
                // that to figure out fandom got broken.
                if (USE_IN_FIRST_COLUMN) {
                    const theDate = "\n(" + savedDate + ")";
                    fandomheader.parentElement.firstElementChild.innerText += theDate;
                } else {
                    // so now I'm just putting at the end of the row
                    row.append(savedDate);
                    //console.log("should be unmod: " + fandomheader.innerText);
                }
            }
        }
    }
})(jQuery);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址