File tree 3 files changed +25
-4
lines changed
3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ <h1>FB Hack</h1>
17
17
< button class ="btn " id ="edit "> Edit</ button >
18
18
< br >
19
19
< button class ="btn " id ="save "> Save</ button >
20
+ < br >
21
+ < button class ="btn " id ="discard "> Discard</ button >
20
22
</ div >
21
23
</ body >
22
24
</ html >
Original file line number Diff line number Diff line change 2
2
3
3
console . log ( "FB Hack Started Loading" ) ;
4
4
5
+
5
6
$ ( "._li" ) . addClass ( "widget_style" ) ;
6
7
$ ( "._li div" ) . sortable ( ) ;
7
8
$ ( "._li div" ) . disableSelection ( ) ;
8
9
9
10
$ ( "#pagelet_bluebar" ) . addClass ( "draggable ui-widget-content" ) ;
10
11
11
- var top = true ;
12
+ var isEditing = false ;
12
13
var eventFcn = function ( event , ui ) {
13
14
if ( ui . position . top > 450 ) {
14
15
$ ( "#blueBar" ) . removeClass ( "fixed_elem" ) ;
@@ -111,12 +112,20 @@ $( document ).ready( function(){
111
112
console . log ( sender . tab ? "from a content script:" + sender . tab . url : "from the extension" ) ;
112
113
if ( request . action == "enter" ) {
113
114
sendResponse ( { farewell : "goodbye" } ) ;
114
- enterEditMode ( ) ;
115
- }
116
- if ( request . action == "exit" ) {
115
+ if ( isEditing ) {
116
+ exitEditMode ( ) ;
117
+ isEditing = false ;
118
+ } else {
119
+ enterEditMode ( ) ;
120
+ isEditing = true ;
121
+ }
122
+ } else if ( request . action == "exit" ) {
117
123
sendResponse ( { farewell : "goodbye" } ) ;
118
124
exitEditMode ( ) ;
119
125
saveToLocationStorage ( ) ;
126
+ } else if ( request . action == "discard" ) {
127
+ exitEditMode ( ) ;
128
+ window . location . reload ( ) ;
120
129
}
121
130
} ) ;
122
131
Original file line number Diff line number Diff line change @@ -23,4 +23,14 @@ $( document ).ready( function(){
23
23
} ) ;
24
24
} ) ;
25
25
} ) ;
26
+ $ ( '#discard' ) . click ( function ( ) {
27
+ chrome . tabs . query ( { active : true , currentWindow : true } , function ( tabs ) {
28
+ var data = {
29
+ action : "discard"
30
+ }
31
+ chrome . tabs . sendMessage ( tabs [ 0 ] . id , data , function ( response ) {
32
+ console . log ( response . farewell ) ;
33
+ } ) ;
34
+ } ) ;
35
+ } ) ;
26
36
} ) ;
You can’t perform that action at this time.
0 commit comments