LibraryThing which of my books tagged

On any site-wide tag page, shows which one's own books have been tagged that way (without having to page through)

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        LibraryThing which of my books tagged
// @namespace   https://greasyfork.org/en/users/11592-max-starkenburg
// @description On any site-wide tag page, shows which one's own books have been tagged that way (without having to page through)
// @include     http*://*librarything.tld/tag/*
// @include     http*://*librarything.com/tag/*
// @version     4
// ==/UserScript==

// Some variables
var cataloglink = document.getElementById("masttab_books");
var username = cataloglink ? cataloglink.getAttribute("href").substr(9) : null; // The chunk after "/catalog/"
var params = "{v: 1.0, width: 500, height: 650, modal: false}";

// Bring in the CSS for the tagmirror lightbox
var link = document.createElement("link");
    link.setAttribute("rel","stylesheet");
    link.setAttribute("href","/css/tagmirror.css");
    link.setAttribute("type","text/css");
document.getElementsByTagName("head")[0].appendChild(link);

// Add a "my books" link to the tag page
if (username) {
    var bodyScripts = document.getElementsByTagName("body");
    var tagNumber = 0;
    for (i=0; bodyScripts.length; i++) {
      if (bodyScripts[i].textContent.indexOf("load_tagtranslation_print(") >= 0) {
        tagNumber = bodyScripts[i].textContent.match(/load_tagtranslation_print\((\d*?),/)[1]; // The number between "load_tagtranslation_print(" and ",", since the number in "fromtag" sometimes doesn't work
        break;
      }
    }
    var myBooks = document.createElement('span');
    myBooks.className = "my-books-tagged";
    var tagText = document.getElementsByClassName("first")[0].textContent;
    tagText = tagText.substring(tagText.indexOf(":") + 1);
    myBooks.innerHTML = '(<a href="javascript:LibraryThing.lightbox.ajax(\'/ajax_tagmirror_tagtobooks.php?view='+username+'&tag='+tagNumber+'\', '+params+')">My books globally tagged '+tagText+'</a>)';
    var aka = document.getElementsByClassName("alsoknownas")[0];
    aka.nextSibling.appendChild(myBooks);
}