-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
39 lines (33 loc) · 1.11 KB
/
background.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
34
35
36
37
38
39
var el = $("table").find("tbody tr td a");
jQuery.fn.exists = function(){return this.length>0;}
chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
if(request.method != "filter")
return;
var reply = request.filtro;
var properties_id = "";
var properties_path = "http://cms.terra.com/terraatomocmaext/secure/checkCold.do?propertiesClose=true&spfMask=00000&spfAId=";
console.log(request.filtro);
el.each(
function(index,element){
var migo = $(element);
text = migo.text();
if(text.indexOf(reply)!=-1)
{
migo.parents("tr").show();
properties_id = migo.attr("href").split("=")[1];
if(!migo.parents("tr").find(".properties_button").exists()) {
migo.parents("tr")
.append($('<td>')
.attr('class', 'properties_button')
.attr('style', 'text-align: center;')
.append('<input type="button" value="Propriedades" onclick="window.open(\''+properties_path+properties_id+'\', \'Terra Channels Filter\',\'scrollbars=1,width=700,height=500, status=yes,resizable=yes\');" >')
);
}
}
else
{
migo.parents("tr").hide();
}
}
);
});