ArkhamDB Dynamic Title

Update the title of ArkhamDB deck pages to include the first 30 characters of the deck name.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         ArkhamDB Dynamic Title
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Update the title of ArkhamDB deck pages to include the first 30 characters of the deck name.
// @author       Chr1Z
// @match        https://*.arkhamdb.com/deck/*
// @icon         https://i.imgur.com/T3vHgln.png
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  // Function to trim the deck name and update the title
  function updateDocumentTitle(deckName) {
    deckName = deckName.trim();

    if (deckName.length > 30) {
      deckName = deckName.substring(0, 30) + '...';
    }

    document.title = deckName + ' · ArkhamDB';
  }

  function updateTitleForView() {
    var deckNameElement = document.querySelector('#wrapper .main.container h1');
    if (deckNameElement) {
      var deckName = deckNameElement.textContent;
      updateDocumentTitle(deckName);
    }
  }

  function updateTitleForEdit() {
    var deckNameInput = document.querySelector('input.decklist-name');
    if (deckNameInput) {
      var deckName = deckNameInput.value;
      updateDocumentTitle(deckName);

      // Update title as user types
      deckNameInput.addEventListener('input', function () {
        var newDeckName = deckNameInput.value;
        updateDocumentTitle(newDeckName);
      });
    }
  }

  // Check if the user is viewing or editing a deck and run the appropriate function
  if (window.location.href.includes('/deck/view/')) {
    window.addEventListener('load', updateTitleForView);
  } else if (window.location.href.includes('/deck/edit/')) {
    window.addEventListener('load', updateTitleForEdit);
  }

})();