// ==UserScript==
// @name 自由帳定期作成(Feederチャット)
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Feederチャットの自由帳を定期的に作り続けるスクリプトです。
// @author You
// @match *.x-feeder.info/*/
// @exclude *.x-feeder.info/*/sp/
// @exclude *.x-feeder.info/*/settings/**
// @require https://greasyfork.org/scripts/396472-yaju1919/code/yaju1919.js?version=798050
// @grant GM.setValue
// @grant GM.getValue
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
let inputCreateBoolBtn, inputFolderId, inputNoteTitle, inputNotePassword, inputNoteText, inputCreateInterval;
// 自由帳を作成する関数
const addNote = (title, folderId, password, text) => { // タイトル, 作成先のフォルダのID, パスワード, 本文
let elm = $("#folder_navi_area").length;
if (!elm) { // 自由帳を既に開いているかチェック
$("#sub_note_icn").click(); // 自由帳を開く
};
setTimeout(() => {
createNote(title, password, password, folderId);
setTimeout(() => {
$("#note_contents").val(text);
setTimeout(() => {
$("#note_save_button").click();
}, 250);
}, 500);
}, 250);
};
//---------------------
const holder = $("
").css("background-color", "gray").prependTo("#main_right")
.append("自由帳定期作成(Feederチャット)
");
let start_flag = false;
let exeMain = () => start_flag ? main() : null;
inputCreateBoolBtn = yaju1919.addInputBool(holder, {
title: "定期作成",
value: false,
change: exeMain,
});
inputFolderId = yaju1919.addInputNumber(holder, {
title: "作成先のフォルダID(必須)",
placeholder: "作成先のフォルダIDを入力(空の場合は0になる)",
save: "AM_inputFolderId",
width: "100%",
value: 0,
min: 0,
max: Infinity,
change: exeMain,
});
inputNoteTitle = yaju1919.addInputText(holder, {
title: "自由帳のタイトル(必須)",
placeholder: "自由帳のタイトルを入力してください",
save: "AM_inputNoteTitle",
width: "100%",
change: exeMain,
});
inputNotePassword = yaju1919.addInputText(holder, {
title: "自由帳のパスワード(任意)",
placeholder: "自由帳のパスワードを入力",
save: "AM_inputNotePassword",
width: "100%",
change: exeMain,
});
inputNoteText = yaju1919.addInputText(holder, {
title: "自由帳の本文(任意)",
placeholder: "自由帳の本文を入力",
save: "AM_inputNoteText",
width: "100%",
textarea: true,
change: exeMain,
});
inputCreateInterval = yaju1919.addInputNumber(holder, {
title: "作成間隔",
placeholder: "自由帳の作成間隔を入力(単位:秒)",
save: "AM_inputCreateInterval",
width: "100%",
value: 10,
min: 10,
max: Infinity,
change: exeMain,
});
holder.append("
");
let result = $("
").css({
"background-color": "pink",
"color": "red",
}).appendTo(holder);
let si;
const main = () => {
const createBoolBtn = inputCreateBoolBtn();
const folderId = inputFolderId();
const noteTitle = inputNoteTitle();
const notePassword = inputNotePassword();
const noteText = inputNoteText();
const createInterval = inputCreateInterval();
if (noteTitle === "" && createBoolBtn) {
result.text("× - 自由帳のタイトルを入力してください");
} else {
result.text("");
clearInterval(si);
if (createBoolBtn) {
si = setInterval(() => {
addNote(noteTitle, folderId, notePassword, noteText);
}, createInterval * 1000);
};
};
};
start_flag = true;
})();