您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add a recreate button to the epicmafia.com setup pages
当前为
// ==UserScript== // @name Recreate Setup on epicmafia.com // @namespace https://greasyforks.org/en/users/159342-cleresd // @description Add a recreate button to the epicmafia.com setup pages // @version 1.00 // @match https://epicmafia.com/setup/* // @include https://epicmafia.com/game/new // @grant GM_setValue // @grant GM_getValue // @run-at document-end // ==/UserScript== // @name VK slaps // @namespace https://greasyforks.org/en/users/159342-cleresd // @description slap everyone who are online on vk.com by typing '@here' or '*here' and press Tab button // @version 1.04 // @require https://code.jquery.com/jquery-3.2.1.min.js // @match https://vk.com/* // @grant none $(document).ready(function() { if ($('.setup_actions').length) $('.setup_actions').after('<div class="play_menu" onclick="my.reCreateSetup()" onmouseover="this.style.borderColor=\'#b11\';this.style.backgroundColor=\'#eee\';" onmouseout="this.style.borderColor=\'#999\';this.style.backgroundColor=\'#eee\';" style="width: 65px"><div class="play_menu_text" style="color: rgb(205, 136, 211);">Recreate</div></div></div>'); else if ($('#subnav').find('li.sel > a.sel').text() === 'Create game') { let recreateSetupFunctionText = GM_getValue("myRecreateSetupFunctionText"); if (recreateSetupFunctionText !== undefined && recreateSetupFunctionText !== '') { $(document.body).append('<script type="text/javascript">' + GM_getValue("myRecreateSetupFunctionText") + '</script>' ); GM_setValue("myRecreateSetupFunctionText", ''); } } }); my = {}; my.reCreateSetup = function () { // Как использовать: // Открыть страницу с сетапом // Нажать F12 // Перейти во вкладку Console // Вставить весь этот текст туда и нажать Enter, текст результата скопируется в буффер // Перейти сюда https://epicmafia.com/game/new // Нажать F12 // Перейти во вкладку Console // Вставить текст из буффера и нажать Enter // Примечание: Опция Multiple Mafias не работает в Main lobby let getDataFromSetupObject = { result: '(function(){', gameOptionIds: [], roles: [], gameSetup: $('.gamesetup').children(), getDataFromNotRandomSetup: function () { for (let i = 0; i < this.gameSetup.length - 3; i++) { let currEl = this.gameSetup[i]; if (currEl.classList.contains('false')) { // get game's option let optionId = '#add_' + currEl.classList[0].split('-')[0]; this.gameOptionIds.push(optionId); } else { // get role // get role's count let roleName = currEl.firstElementChild.classList[1]; roleName += currEl.firstElementChild.classList.contains('mafia_red') ? '.mafia_red' : ':not(.mafia_red)'; let roleCount = currEl.firstElementChild.hasChildNodes() ? currEl.firstElementChild.firstElementChild.textContent : 1; this.addRoles(roleName, roleCount); } } }, addRoles: function (roleName, roleCount) { for (let j = 0; j < roleCount; j++) { this.roles.push('\'.' + roleName + '\''); } }, getDataFromRandomSetup: function () { for (let i = 0; i < this.gameSetup.length - 3; i++) { let currEl = this.gameSetup[i]; if (currEl.classList.contains('false')) { // get game option let optionId = '#add_' + currEl.classList[0].split('-')[0]; this.gameOptionIds.push(optionId); } else { // get roles let $allRoles = $('.allroles_align').children(); for (let i = 0; i < $allRoles.length; i++) { this.addRandomRole($allRoles[i]); } } } }, addRandomRole: function (randomRole) { let roleName = randomRole.classList[1]; roleName += randomRole.classList.contains('mafia_red') ? '.mafia_red' : ':not(.mafia_red)'; this.roles.push('\'.' + roleName + '\''); }, getResult: function () { let addBeforeRoles = ''; let addAfterRoles = ''; if ($('.gamesetup > .probabilities').length === 1) { this.getDataFromRandomSetup(); } else { this.getDataFromNotRandomSetup(); } // closed roles on the top to add all roles in correct way let closedRolesOptionIndex; if ((closedRolesOptionIndex = this.gameOptionIds.indexOf('#add_closedroles')) !== -1) { // if exist this.gameOptionIds.splice(closedRolesOptionIndex, 1); addBeforeRoles += '\n$(\'#add_closedroles\').click();\n'; } // make sure it would be all right with whisper game option let whisperOptionIndex; if ((whisperOptionIndex = this.gameOptionIds.indexOf('#add_whisper')) !== -1) { // if exist this.gameOptionIds.splice(whisperOptionIndex, 1); } else { // if doesn't exist this.gameOptionIds.push('#add_whisper'); } // add all game options to the result line for (let i = 0; i < this.gameOptionIds.length; i++) { let optionId = this.gameOptionIds[i]; addAfterRoles += '$(\'' + optionId + '\').click();\n'; } if ($('#prob_village').find('> div > .uniquealign').length === 1) { addAfterRoles += '$(\'#add_unique_village\').click();\n'; } if ($('#prob_mafia').find('> div > .uniquealign').length === 1) { addAfterRoles += '$(\'#add_unique_mafia\').click();\n'; } if ($('#prob_third').find('> div > .uniquealign').length === 1) { addAfterRoles += '$(\'#add_unique_third\').click();\n'; } // add all roles to the result line this.result += '\nlet roles = [' + this.roles + '];\n'; this.result += ` let checkExist = setInterval(function() { if ($(roles[0]).length) { clearInterval(checkExist);\n` + addBeforeRoles + ` for (let i = 0; i < roles.length; i++) { $(roles[i]).prev().children('.inc').click(); }\n` + addAfterRoles + ` } }, 500);\n`; return this.result += '\n})();'; } }; this.result = getDataFromSetupObject.getResult(); GM_setValue("myRecreateSetupFunctionText", this.result); window.open('https://epicmafia.com/game/new', '_blank'); }