Skip to content

Commit

Permalink
#203 websockets
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizzick committed Apr 27, 2016
1 parent 3208b7b commit 09d3dec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var contentPage = {

var i18n = chrome.i18n;


//TODO: Move it somewhere
function pageMessageListener(event) {
if (!(event.source == window &&
event.data.direction &&
Expand All @@ -31,9 +31,6 @@ function pageMessageListener(event) {
return;
}

console.log('--- content script received message');
console.log(event.data);

var message = {
type: 'processShouldCollapse',
elementUrl: event.data.elementUrl,
Expand Down
7 changes: 1 addition & 6 deletions Extension/lib/content-script/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
var overrideWebSocket = function () {

function FakeWebSocket(server, protocol) {
console.log('WS init: ' + server + ' ' + protocol);

this.readyState = 0; // CONNECTING
var that = this;

// Send a message to the background page to check if the request should be blocked
function messageListener(event) {
if (!(event.data.direction &&
event.data.direction == "to-page-script" &&
Expand All @@ -32,9 +29,6 @@ var overrideWebSocket = function () {
return;
}

console.log('--- Page received message');
console.log(event.data);

setTimeout(function () {
if (event.data.collapse == true) {
that.readyState = 3; // CLOSED
Expand All @@ -59,6 +53,7 @@ var overrideWebSocket = function () {
documentUrl: document.URL
};

// Send a message to the background page to check if the request should be blocked
window.postMessage(message, "*");
}

Expand Down

0 comments on commit 09d3dec

Please sign in to comment.