Bitcointalk Mention Autocomplete

a tool for Bitcointalk Mention Autocomplete

このスクリプトは単体で利用できません。右のようなメタデータを含むスクリプトから、ライブラリとして読み込まれます: // @require https://update.greasyfork.org/scripts/593467/1915978/Bitcointalk%20Mention%20Autocomplete.js

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

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

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

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

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

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

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

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

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

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

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

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

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

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

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Bitcointalk Mention Autocomplete
// @namespace    https://greasyfork.org/users/gakjahat
// @version      0.1
// @description  Fitur autocomplete mention untuk username Bitcointalk langsung dari thread tanpa database.
// @author       gakjahat
// @match        https://bitcointalk.org/*
// @include      https://bitcointalk.org/*
// @grant        none
// ==UserScript==

(function() {
    'use strict';

    function getThreadUsernames() {
        const userLinks = document.querySelectorAll('td.postercol b a, .mirrored b a');
        const usernames = new Set();

        userLinks.forEach(link => {
            if (link.textContent) {
                usernames.add(link.textContent.trim());
            }
        });

        return Array.from(usernames);
    }

    const textarea = document.querySelector('textarea[name="message"]');

    if (textarea) {
        textarea.addEventListener('input', () => {
            const text = textarea.value;
            const cursorPosition = textarea.selectionStart;
            const lastWord = text.slice(0, cursorPosition).split(/\s+/).pop();

            if (lastWord && lastWord.startsWith('@')) {
                const query = lastWord.slice(1).toLowerCase();
                const availableUsers = getThreadUsernames();
                const matches = availableUsers.filter(user =>
                    user.toLowerCase().startsWith(query)
                );
                console.log('Rekomendasi Username:', matches);
            }
        });
    }
})();