F95 Quick Game Templates

Adds more action buttons to the toolbar when making a game request on f95.

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
// ==UserScript==
// @name        F95 Quick Game Templates
// @namespace   1330126-edexal
// @match       *://f95zone.to/forums/game-requests.3/post-thread*
// @icon        https://external-content.duckduckgo.com/ip3/f95zone.to.ico
// @grant       none
// @version     1.1.1
// @author      Edexal
// @license     Unlicense
// @description Adds more action buttons to the toolbar when making a game request on f95.
// ==/UserScript==
(() => {
    let styleCSS = `
    .edexal-btn{
        color:yellow !important;
    }
    `;
    const NEW_TEMPLATE = { title: "[GAME ENGINE] Game Name [Version][Developer]",
                          body: `[CENTER](COVER ART; DELETE THIS)

[B]Overview:[/B]
(STORY OVERVIEW GOES HERE AND USE A SPOILER TAG IN-CASE OF A WALL OF TEXT; DELETE THIS)[/CENTER]

[B]Thread Updated[/B]: (USE "YYYY-MM-DD" NUMBERS ONLY, DATE ADDED TO F95ZONE ; DELETE THIS)
[B]Release Date[/B]: (USE "YYYY-MM-DD" NUMBERS ONLY, DATE RELEASE BY DEV; DELETE THIS)
[B]Developer[/B]: Patreon - Website
[B]Censored[/B]:
[B]Version[/B]:
[B]OS[/B]: (REN'PY GAMES WITH "PC" IN THE TITLE INCLUDE BOTH WINDOWS + LINUX, MAKE SURE TO TYPE BOTH; DELETE THIS)
[B]Language[/B]: English
[B]Genre[/B]:
[SPOILER]
(GENRE TAGS HERE, CAPITALIZE EACH TAG FOR PARITY, DELETE THIS)
[/SPOILER]

[B]Installation[/B]:
[SPOILER]
1. Extract and run.
[/SPOILER]

[B]Changelog[/B]:
[SPOILER]
(CHANGELOG GOES HERE. IF NO CHANGELOG IS AVAILABLE, USE "vX.XX Release" OR SIMILAR; DELETE THIS LINE)
[/SPOILER]

[B]Developer Notes[/B]:
[SPOILER]
(IN CASE THE DEVELOPER WISHES TO SHARE SOME INFO REGARDING THE GAME; DELETE THIS ENTIRE BLOCK IF NONE)
[/SPOILER]

(ADD ANY OTHER BLOCK FOLLOWING THE SAME FORMATTING AS ABOVE IF NECESSARY HERE; DELETE THIS LINE)
[CENTER][B][SIZE=6]DOWNLOAD[/SIZE][/B]
[SIZE=5][B]Win[/B]: TORRENT - MIRROR - MIRROR - MIRROR
[B]Linux[/B]: TORRENT - MIRROR - MIRROR - MIRROR
[B]Mac[/B]: TORRENT - MIRROR - MIRROR - MIRROR
[B]Others[/B]: COMPRESSED - ANDROID (OR UNOFFICIAL ANDROID)

[B]Patches[/B]: INCEST PATCH - BUGFIX
[B]Extras[/B]: WALKTHROUGH - 100% SAVE - MOD - MOD2 - MOD3[/SIZE]
[SIZE=1](THANK YOU NOTES AND UNOFFICIAL ANDROID MESSAGE GOES, ALWAYS AT THE VERY BOTTOM OF ALL DL LINKS; EXAMPLE: "Unofficial build by [USER=1]@F95[/USER]. Thank you [USER=2222]@Bloo[/USER] for sharing the game and [USER=92]@TCMS[/USER] for the walkthrough."; DELETE THIS LINE)[/SIZE]

(SAMPLES/SCREENSHOTS; DELETE THIS)[/CENTER]`};
    const REQ_TEMPLATE = {title:"[Store][$Price] Game Name [Version][Developer]",
                          body: `Title:
Developer website:
Language:
Samples:

[CENTER][B][COLOR=#ff0000]Rules - Remove this before posting.[/COLOR][/B][/CENTER]
*Any Online only or Multiplayer requests will be denied and deleted.
*Don't ask for games that haven't been released yet.
*Don't request more than 1 game per request (this includes siterip).
*If the game is a translated game (from any language to English) a link to the translator page is required like [URL='https://ulmf.org/']ULMF[/URL] links, if not, it's not required.`};
    const UPDATE_TEMPLATE = {title:"[Store][$Price] Game Name [Version][Developer]",
                             body:`Title:
Thread: (link to thread on F95zone)
Developer website:
Version:

[CENTER][B][COLOR=#ff0000]Rules - Remove this before posting.[/COLOR][/B][/CENTER]
*Any Online only or Multiplayer requests will be denied and deleted.
*Don't ask for games that haven't been released yet.
*Don't request more than 1 game per request (this includes siterip).
*If the game is a translated game (from any language to English) a link to the translator page is required like [URL='https://ulmf.org/']ULMF[/URL] links, if not, it's not required.`};
    //Apply custom styles in a style tag
    function applyCSS(css) {
        let styleEl = document.querySelector("style");
        if (styleEl === null) {
            styleEl = document.createElement('style');
        }
        styleEl.appendChild(document.createTextNode(css));
        document.head.appendChild(styleEl);
    }
    function addButton(){
        let toolbarEl = document.querySelector('.fr-toolbar');
        toolbarEl.insertAdjacentHTML('beforeend','<div class="fr-separator fr-vs" role="separator" aria-orientation="vertical"></div>' +
            '<button aria-controls="dropdown-menu-xfTemp-1" aria-expanded="false" aria-haspopup="false" class="fr-command fr-btn fr-dropdown fr-btn-font_awesome edexal-btn" data-cmd="xfTemp"\n' +
            '        id="xfTemp-1" role="button" tabindex="-1"\n' +
            '        type="button" title="Templates">\n' +
            '    <i aria-hidden="true" class="fas fa-file-word"></i>\n' +
            '    <span class="fr-sr-only">Templates</span>\n' +
            '</button>\n' +
            '<div aria-hidden="true" aria-labelledby="xfTemp-1" class="fr-dropdown-menu" id="dropdown-menu-xfTemp-1" role="listbox">\n' +
            '    <div class="fr-dropdown-wrapper" role="presentation">\n' +
            '        <div class="fr-dropdown-content" role="presentation">\n' +
            '            <ul class="fr-dropdown-list" role="presentation">\n' +
            '                <li role="presentation"><a class="fr-command" data-cmd="xfTemp" data-param1="xfTempNew" role="option"\n' +
            '                                           tabindex="-1" title="New Game Template">New Game Template</a></li>\n' +
            '                <li role="presentation"><a class="fr-command" data-cmd="xfTemp" data-param1="xfTempReq" role="option"\n' +
            '                                           tabindex="-1" title="Request Game Template">Request Game Template</a></li>\n' +
            '                <li role="presentation"><a class="fr-command" data-cmd="xfTemp" data-param1="xfTempUpdate" role="option"\n' +
            '                                           tabindex="-1" title="Update Game Template">Update Game Template</a></li>\n' +
            '            </ul>\n' +
            '        </div>\n' +
            '    </div>\n' +
            '</div>' +
            '<button id="xfTagList-1" title="Go To Tag List" type="button" tabindex="-1" role="button" class="fr-command fr-btn fr-btn-xf_font_awesome_5 edexal-btn" data-cmd="xfTagList"><i class="far fa-tags" aria-hidden="true"></i><span class="fr-sr-only">Go To Tag List</span></button>');
    }
    function refreshTextArea(){
        let textAreaEl = document.querySelector(".fr-element") //Text Area Element
        textAreaEl.replaceChildren();//Text Area Element
        let preEl = document.createElement("pre");
        textAreaEl.append(preEl); //Text Area Element
    }

    function displayTextClick(e,template){
        refreshTextArea();
        let txt = document.createTextNode(template.body);
        document.querySelector(".fr-element").firstElementChild.append(txt); //Text Area Element
        document.querySelector('#xfTemp-1').classList.remove('fr-active','fr-selected');
        e.target.classList.remove('fr-selected');
        document.querySelector('[placeholder~=title]').value = template.title; //Thread title Element
    }
    function goToTagListClick(e){
        window.open("https://f95zone.to/threads/tags-rules-and-list-updated-2024-01-29.10394");
    }

    function run(){
        applyCSS(styleCSS);
        addButton();
        document.querySelector('[title=\"New Game Template\"]').addEventListener('click',(e) => displayTextClick(e,NEW_TEMPLATE));
        document.querySelector('[title=\"Request Game Template\"]').addEventListener('click',(e) => displayTextClick(e,REQ_TEMPLATE));
        document.querySelector('[title=\"Update Game Template\"]').addEventListener('click',(e) => displayTextClick(e,UPDATE_TEMPLATE));
        document.querySelector('#xfTagList-1').addEventListener('click',(e) => goToTagListClick(e));
    }
    setTimeout(run,2500);
})();