Greasy Fork is available in English.
28/09/2024, 00:38:02
当前为
// ==UserScript==
// @name Colorful Repertoire With Music quality
// @namespace Violentmonkey Scripts
// @match https://*.popmundo.com/World/Popmundo.aspx/Artist/Repertoire/*
// @grant none
// @license M.I.T
// @version 1.0
// @author tROY
// @description 28/09/2024, 00:38:02
// ==/UserScript==
const currentUrl = window.location.href;
// Usa uma expressão regular para extrair o número após a última barra
const bandId = currentUrl.split('/').pop();
const urlDomain = window.location.hostname;
console.log(urlDomain)
jQuery(document).ready(function () {
// Cria um iframe único que será reutilizado para cada link e o oculta
const iframe = jQuery('<iframe>', {
id: 'songIframe',
width: '0px',
height: '0px',
css: {
display: 'none' // Deixa o iframe oculto inicialmente
}
}).appendTo('#ppm-wrapper');
// Seleciona todos os links da tabela
const links = jQuery('#tablesongs tbody tr td a');
let currentIndex = 0;
// Função para processar um link
function processLink() {
if (currentIndex >= links.length) {
console.log('Processamento concluído para todos os links.');
iframe.remove(); // Remove o iframe após concluir o processamento de todos os links
return;
}
const currentLink = jQuery(links[currentIndex]);
const originalText = currentLink.text();
const currentLinkHref = currentLink.attr('href');
const linkFormatted = "https://" + urlDomain + currentLinkHref;
let notaMelodia = 0;
let notaLetra = 0;
let bandaPropria = false;
// Atualiza o iframe com o novo link
iframe.attr('src', linkFormatted);
iframe.off('load').on('load', function () {
const iframeContent = iframe.contents();
// Seleciona o primeiro div com a classe 'box'
let div1stBox = iframeContent.find('div.box').first();
// Captura o href do primeiro <a> e extrai o ID
const bandHref = div1stBox.find('a[href^="/World/Popmundo.aspx/Artist/"]').attr('href');
if (bandHref) {
const bandIdFromHref = bandHref.split('/').pop(); // Extrai o ID do href
if (bandIdFromHref === bandId) {
bandaPropria = true;
}
}
// Seleciona a segunda div com a classe 'box'
let div2ndBox = iframeContent.find('div.box').eq(1);
// Seleciona o primeiro e o segundo <a> dentro do <p> e obtém o título
const melodiaTitle = div2ndBox.find('p a').eq(0).attr('title');
const letraTitle = div2ndBox.find('p a').eq(1).attr('title');
// Extraindo a nota antes da barra "/26"
if (melodiaTitle && letraTitle) {
notaMelodia = melodiaTitle.split('/')[0];
notaLetra = letraTitle.split('/')[0];
console.log(`Link ${currentIndex + 1} - Nota da Melodia: ${notaMelodia}`);
console.log(`Link ${currentIndex + 1} - Nota da Letra: ${notaLetra}`);
// Atualiza o texto do <a> original com as notas
let newText = `${originalText} (${notaMelodia}/${notaLetra})`;
currentLink.text(newText);
// Aplica as cores, estilo de fonte, e o contorno
if (bandaPropria) {
currentLink.css({
'color': 'green',
'font-weight': 'bold', // Verde e negrito para músicas próprias
});
} else {
currentLink.css({
'color': 'yellow',
'font-weight': 'bold', // Amarelo para covers/compradas
'text-shadow': '1px 1px 0px black, -1px -1px 0px black, 1px -1px 0px black, -1px 1px 0px black'
});
}
} else {
console.error('Não foi possível encontrar os títulos para as notas da melodia e da letra.');
}
// Avança para o próximo link
currentIndex++;
processLink();
});
}
// Inicia o processamento do primeiro link
processLink();
});