מפתח הברגים של ניב

פותח אתגרים שבועיים בלחיצת כפתור

目前为 2021-01-09 提交的版本。查看 最新版本

// ==UserScript==
// @name         מפתח הברגים של ניב
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  פותח אתגרים שבועיים בלחיצת כפתור
// @author       Muffin24
// @match        https://www.fxp.co.il/forumdisplay.php?f=*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
	if (forumname.includes("אתגרים") || forumname.includes("הפרסות") && !forumname.includes('ארכיון')) {
		$('#above_threadlist').append(`<center><button style="font-size:0.9rem">פתיחת אתגרים שבועיים</button></center>`).click(function() {
			const id = document.querySelector("#breadcrumb > ul > li:nth-child(3) a").href.split('=')[1];
			$.getJSON('https://fxptest.000webhostapp.com/temp/?id=' + id, function(response) {
                for (const thread of [...document.querySelectorAll('#threads .title')]) {
                    for (const [key, value] of Object.entries(response.forums)) {
                        if (!new RegExp(value).test(thread.text)) return;
                        const message = Object.values(response.forums[key].members || {}).map(i => '[taguser]' + i + '[/taguser]').join('\n') + '\nבבקשה להגיש אתגרים שבועיים';
                        newReplay(thread.href.split('=')[1],USER_ID_FXP, SECURITYTOKEN, message);
                    }
                }
			}).done(function() {
               alert('ניב פתח את האתגרים השבועיים בהצלחה')
            })
        })
    }

    function newReplay(THREAD_ID_FXP, USER_ID_FXP, SECURITYTOKEN, message) {
        console.log(message);
        const body = new FormData();
        body.append("do", "postreply");
        body.append("message", message);
        body.append("message_backup", message);
        body.append("wysiwyg", 1);
        body.append("loggedinuser", USER_ID_FXP);
        body.append("securitytoken", SECURITYTOKEN);
        body.append("parseurl", 1);
        body.append("signature", 1);
        body.append("ajax", 1);
        body.append("p", "who cares");
        fetch("https://www.fxp.co.il/newreply.php?t=" + THREAD_ID_FXP, { method: 'POST', body }).catch(error => console.log('error', error));
    }
})();