-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
53 lines (41 loc) · 1.46 KB
/
content.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
$(document).ready(function(){
function raygunOn() {
console.log('raygun on!');
// $('*').hover(function() {
// $( this ).addClass( "raygun-selected" );
// }, function() {
// $( this ).removeClass( "raygun-selected" );
// });
$( "*:not(#raygun-off)" ).not('#raygun-off').on( "mouseenter.raygun mouseleave.raygun", function( event ) {
$( this ).toggleClass( "raygun-selected" );
});
$('*').not('#raygun-off').on('click.raygun', function(e){
e.stopPropagation();
e.preventDefault();
$(this).remove();
// chrome.runtime.sendMessage({greeting: "hello"}, function(response) {
// console.log(response.farewell);
// });
});
};
function raygunOff(){
$('*').off('.raygun');
console.log('raygun disarmed');
};
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
console.log(sender.tab ? "from a content script:" + sender.tab.url : "from the extension");
console.log(request.raygun);
if (request.raygun == "on"){
sendResponse({raygun: "Raygun is ready to kill DOM elements!"});
raygunOn();
}
});
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
console.log(sender.tab ? "from a content script:" + sender.tab.url : "from the extension");
console.log(request.raygun);
if (request.raygun == "off"){
sendResponse({raygun: "Raygun is disarmed"});
raygunOff();
}
});
});