Skip to content

Commit 6b63a2b

Browse files
committed
added operations to the extension to stop edit and discard
1 parent 9c20cf9 commit 6b63a2b

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

extension/app/popup.html

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ <h1>FB Hack</h1>
1717
<button class="btn" id="edit">Edit</button>
1818
<br>
1919
<button class="btn" id="save">Save</button>
20+
<br>
21+
<button class="btn" id="discard">Discard</button>
2022
</div>
2123
</body>
2224
</html>

extension/app/scripts/contentscript.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
console.log("FB Hack Started Loading");
44

5+
56
$("._li").addClass("widget_style");
67
$("._li div").sortable();
78
$("._li div").disableSelection();
89

910
$("#pagelet_bluebar").addClass("draggable ui-widget-content");
1011

11-
var top = true;
12+
var isEditing = false;
1213
var eventFcn = function(event, ui) {
1314
if( ui.position.top > 450){
1415
$("#blueBar").removeClass("fixed_elem");
@@ -111,12 +112,20 @@ $( document ).ready( function(){
111112
console.log(sender.tab ? "from a content script:" + sender.tab.url : "from the extension");
112113
if (request.action == "enter") {
113114
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") {
117123
sendResponse({farewell: "goodbye"});
118124
exitEditMode();
119125
saveToLocationStorage();
126+
} else if (request.action == "discard"){
127+
exitEditMode();
128+
window.location.reload();
120129
}
121130
});
122131

extension/app/scripts/popup.js

+10
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,14 @@ $( document ).ready( function(){
2323
});
2424
});
2525
});
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+
});
2636
});

0 commit comments

Comments
 (0)