-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
80 lines (63 loc) · 2.74 KB
/
content.js
File metadata and controls
80 lines (63 loc) · 2.74 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse){
if(msg.text === 'report_back') {
grabLink();
}
});*/
var blacklist=["microsoft","bing","mail","sign","log","edit","delete","remove","pdf","#","jpg","jpeg","png","chrome","itunes","porn","sex","javascript","gif","mp3","xml","rss","acc","zip","mp4",".exe",".dmg","tel:"]
chrome.runtime.onMessage.addListener(function(msg, sender, sendResponse) {
setInterval(function(){
window.scrollBy(0, 25);
},50)
/* If the received message has the expected format... */
if (msg.text && (msg.text == "report_back")) {
/* Call the specified callback, passing
the web-pages DOM content as argument */
// alert("hi from content script"); //DOESN'T WORK ... do we ever get in here?
grabLink(sendResponse,msg.token)
}
//document.body.innerHTML += '<div style="position:fixed;top:0;left:0;right:0;bottom:0;z-index:100;background:url('+chrome.extension.getURL("overlay_right.png")+');background-position:bottom;background-repeat:no-repeat"></div>';
});
function grabLink(sendResponse,token) {
var as = [].slice.call(document.getElementsByTagName("a"))
links = as.filter(function(obj){
for (i in blacklist){
if(obj.href.toLowerCase().indexOf(blacklist[i])!=-1){
return false;
}
}
return obj.href!="" && obj.href.indexOf("#")!=0 && obj.href.indexOf("mailto")==-1&& obj.href.indexOf("pdf")==-1 && obj.href.indexOf("jpg")==-1&& obj.href.indexOf("png")==-1
});
console.log(links);
window.removeEventListener('onbeforeunload',true)
window.removeEventListener('onbeforeunload',false)
if(links.length<3){
sendResponse({url:"NOLINK",token:token,title:document.title});
return
}
var randomIndex = Math.floor(Math.random() * links.length);
console.log(randomIndex);
sendResponse({url:links[randomIndex].href,token:token,title:document.title});
links[randomIndex].removeEventListener('click',true)
links[randomIndex].removeEventListener('click',false)
//links[randomIndex].click()
}
function replaceSrc()
{
[]
.forEach
.call(document.querySelectorAll('a[target="_blank"]'),
function(link) {
link.removeAttribute('target');
});
var images = document.getElementsByTagName('img');
for(var i = 0; i < images.length; i++)
{
var img = images[i];
// img.src = 'https://i.imgur.com/7hxzUvX.jpg';
}
}
replaceSrc();
window.onunload = function() {
alert('by by Honey')
};
//document.body.innerHTML += '<div style="position:fixed;top:0;left:0;right:0;bottom:0;z-index:100;background:url('+chrome.extension.getURL("overlay_right.png")+');background-position:bottom;background-repeat:no-repeat"></div>';