-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyscript.js
More file actions
126 lines (77 loc) · 2.71 KB
/
myscript.js
File metadata and controls
126 lines (77 loc) · 2.71 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
$(document).ready(function(){
$('body').append('test');
});
chrome.extension.onConnect.addListener(function(port) {
port.onMessage.addListener(function(msg) {
data= JSON.stringify($('#junkdrawer').clone().html());
port.postMessage({reply: data});
$('body').append('msg '+ msg);
});
});
$('body').prepend('<div class="ui-widget-content" id="junkdrawer"><h3 class="ui-widget-header"></h3><div id="data" ></div></div> ');
function update(){
// We can do xhr and can access local files like this:
$.get("chrome-extension://ginfiphcnjiiecbdmgmagnhjjcplmjco/test", function(data){
// do something with data.
});
}
$('#junkdrawer').hover(function(e){
e.stopPropagation();
$('#junkdrawer').css({opacity:1});
$('#junkdrawer').css({height:500, width:250, opacity:1} );
});
$('#junkdrawer').click(function(e){
e.stopPropagation();
});
$('body').click(function(){
tagElements();
$('#junkdrawer').css({opacity:.5, width:5});
});
$( "#junkdrawer" ).droppable({
drop: function( event, ui ) {
console.log(event);
$(ui.draggable[0]).css({position:'relative', top:0, left:0});
console.log(ui.draggable[0]);
console.log(localStorage.el);
$('#data').append($('<div />').html(ui.draggable));
return false;
}
});
function tagElements(){
$('a').draggable();
$('a').css({border:"2px groove blue"});
$('img').css({border:"5px groove green"});
$('img').draggable();
$('img').click(function(e){
e.stopPropagation();
e.preventDefault();
$('#data').append($('<div />').html(this));
});
$('p').css({border:"2px groove yellow"});
$('p').draggable();
$('span').css({border:"2px groove yellow"});
$('span').draggable();
}
try {
$('*').each(function(el){
if($(this).css('background-image') != 'none') {
console.log($(this).css('background-image'));
$(this).css({border:'2px solid red'});
$(this).draggable();
}
});
$('*').contents().each(function(){
if (this.nodeType == 3){
if (this.nodeValue.trim() != "" && this.parentNode !="")
$(this).text($('<p />').text($(this))).css({'font-size':'50pt', 'background-color':'yellow'});
}
});
}
catch(e) {
console.log(e);
}
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
sendResponse(JSON.stringify($('#junkdrawer').html()));
$('body').append('sending msg<br />');
});