sendMessage

各チャットサイトでメッセージを送信するライブラリです。

Ajankohdalta 4.12.2020. Katso uusin versio.

Tätä skriptiä ei tulisi asentaa suoraan. Se on kirjasto muita skriptejä varten sisällytettäväksi metadirektiivillä // @require https://update.greasyfork.org/scripts/417889/876698/sendMessage.js.

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

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         sendMessage
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @license      MIT
// @description  各チャットサイトでメッセージを送信するライブラリです。
// @author       You
// ==/UserScript==

(function(window) {
    'use strict';
    // プライベート関数
    function _postJSON(url, data, headers) {
        var xhr = new XMLHttpRequest();
        xhr.open("POST", url);
        xhr.setRequestHeader("content-type", "application/json");
        Object.keys(headers).forEach(function(k) {
            xhr.setRequestHeader(k, headers[k]);
        });
        xhr.send(JSON.stringify(data));
    };

    // エクスポート
    window.sendMessage = function(str, discord_token) {
        if (!str) return;
        // サイト別処理
        switch (location.href.replace(/^.+?\/\/|\/.*$/g, "").replace(/^(www)[0-9]+(\.x-feeder\.info)$/, "$1$2").replace(/^[^\.]*\.(open2ch\.net)$/, "$1")) {
            case "www.x-feeder.info":
                if (str.length > 1000) return;
                _postJSON(location.href + "/post_feed.php", {
                    name: document.querySelector("#post_form_name").value,
                    comment: str,
                    is_special: 0,
                    category_id: 0
                }, {});
                break;
            case "pictsense.com":
                if (str.length > 200) return;
                document.querySelector("#chatText").value = str;
                document.querySelector("#chatSubmitButton").click();
                break;
            case "drrrkari.com":
                document.querySelector("textarea[name='message']").value = str;
                document.querySelector("input[name='post']").click();
                break;
            case "himachat.jp":
                if (str.length > 150) return;
                document.querySelector(".frombar").value = str;
                document.querySelector(".formbtn").click();
                break;
            case "www.3751chat.com":
                if (str.length > 1000) return;
                document.querySelector("#chat").value = str;
                document.querySelector("#say").click();
                break;
            case "discord.com":
                if (str.length > 2000 || !discord_token) return;
                _postJSON("https://discord.com/api/v8/channels/" + location.href.match(/^https:\/\/discord\.com\/channels\/[0-9]+\/([0-9]+)$/)[1] + "/messages", {
                    content: str,
                    tts: false
                }, {
                    authorization: discord_token
                });
                break;
            case "open2ch.net":
                document.querySelector("#MESSAGE").value = str;
                document.querySelector("#submit_button").click();
                break;
        };
    };
})(window);