Greasy Fork is available in English.
convida todo mundo da lista de relacionamentos
当前为
// ==UserScript==
// @name Convidador de casamentos (em testes)
// @namespace Violentmonkey Scripts
// @description convida todo mundo da lista de relacionamentos
// @include https://*.popmundo.com/World/Popmundo.aspx/Locale/MarriagePartners*
// @grant none
// @license MIT
// @version 1.3
// @author -
// @description 03/12/2024, 16:27:12
// ==/UserScript==
(function () {
// Verifica se jQuery está disponível
if (typeof jQuery === 'undefined') {
console.error('jQuery não encontrado. Certifique-se de que o script está sendo executado em um ambiente com jQuery.');
return;
}
// Função auxiliar para aguardar o carregamento do iframe
function AwaitIframeLoad(iframe) {
return new Promise((resolve) => {
iframe.on('load', function () {
resolve(iframe.contents());
});
});
}
// Procurar a div com class "ofauto bmargin10"
const targetDiv = jQuery('.ofauto.bmargin10');
if (targetDiv.length === 0) {
console.warn('Div com a classe "ofauto bmargin10" não encontrada.');
return;
}
// Inserir uma nova div com um botão logo abaixo da div encontrada
const newDiv = jQuery(`
<div>
<input type="button" class="cnf" value="Convidar da lista de relacionamentos" />
</div>
`);
targetDiv.after(newDiv);
// Adicionar evento ao botão
jQuery('.cnf').on('click', async function () {
// Criar o iframe
const iframe = jQuery('<iframe>', {
style: 'width: 400px; height: 400px; border: 0; display: block; position: absolute; z-index: 9999;',
}).appendTo('body');
// Carregar a página de relacionamentos
iframe.attr('src', '/World/Popmundo.aspx/Character/Relations/');
const iframeContents = await AwaitIframeLoad(iframe);
const ids = [];
// Procurar todos os links no iframe que contêm os IDs
iframeContents.find('a').each(function () {
const href = jQuery(this).attr('href');
if (href && href.includes('/World/Popmundo.aspx/Character/')) {
const idMatch = href.match(/\/Character\/(\d+)/);
if (idMatch && idMatch[1]) {
ids.push(idMatch[1]);
}
}
});
console.log('IDs coletados:', ids);
// Atualizar o src do iframe para a página inicial
iframe.attr('src', window.location.href);
await AwaitIframeLoad(iframe);
// Iterar sobre os IDs
for (const id of ids) {
const newContents = iframe.contents();
// Clicar no botão de detalhes do casamento
newContents.find('input[name="ctl00$cphLeftColumn$ctl00$repUpcomingWeddings$ctl01$btnWeddingDetails"]').click();
await AwaitIframeLoad(iframe);
// Preencher o ID no campo de texto
newContents.find('input[name="ctl00$cphLeftColumn$ctl00$txtDetailsFindCharacterID"]').val(id);
// Clicar no botão "Encontrar"
newContents.find('input[name="ctl00$cphLeftColumn$ctl00$btnDetailsFind"]').click();
await AwaitIframeLoad(iframe);
// Procurar o botão de convite dentro do iframe
const inviteButton = newContents.find('input[name="ctl00$cphLeftColumn$ctl00$repDetailsFindGuest$ctl01$btnInvite"]');
if (inviteButton.length) {
inviteButton.click();
} else {
console.error('Botão de convite não encontrado para o ID:', id);
}
}
// Remover o iframe após a execução
iframe.remove();
alert('Todos os convites foram enviados!');
});
})();