-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
33 lines (33 loc) · 1.21 KB
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(tab.id, {
code: `
var elementosStrong=document.querySelectorAll('strong[title]');
var urlsElegibles=[];
for(var i=0;i<elementosStrong.length;i++){
var elemento=elementosStrong[i];
var url=elemento.textContent.trim();
var columnaEligible=obtenerColumnaEligible(elemento);
if(columnaEligible&&columnaEligible.querySelector('.daisy-text--green')){
urlsElegibles.push(url);
}
}
var textarea=document.createElement('textarea');
textarea.value=urlsElegibles.join('\\n');
document.body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
document.body.removeChild(textarea);
console.log('Las URLs elegibles se han copiado en el portapapeles.');
function obtenerColumnaEligible(elementoStrong){
var fila=elementoStrong.closest('.daisy-table__row');
if(fila){
var columnas=fila.querySelectorAll('.daisy-table__cell');
if(columnas.length>=5){
return columnas[4];
}
}
return null;
}
`
});
});