@@ -18,10 +18,10 @@ function isLocalNetworkURL(url) {
18
18
19
19
( async ( ) => {
20
20
let URL = window . location . toString ( ) ;
21
- console . log ( "cursors: contentScript.js: URL: " + URL ) ;
21
+ // console.log("cursors: contentScript.js: URL: " + URL);
22
22
23
23
if ( isLocalNetworkURL ( URL ) ) {
24
- console . log ( "cursors: contentScript.js: URL is on the local-network. Exiting..." ) ;
24
+ // console.log("cursors: contentScript.js: URL is on the local-network. Exiting...");
25
25
return ;
26
26
}
27
27
@@ -33,9 +33,9 @@ function isLocalNetworkURL(url) {
33
33
blacklist = await browser . storage . local . get ( [ "cursors.blacklist" ] ) ;
34
34
}
35
35
36
- console . log ( "cursors: contentScript.js: blacklist: " + blacklist [ "cursors.blacklist" ] ) ;
36
+ // console.log("cursors: contentScript.js: blacklist: " + blacklist["cursors.blacklist"]);
37
37
if ( blacklist [ "cursors.blacklist" ] . includes ( URL ) ) {
38
- console . log ( "contentScript.js: " + URL + " is blacklisted." ) ;
38
+ // console.log("contentScript.js: " + URL + " is blacklisted.");
39
39
return ;
40
40
}
41
41
@@ -70,6 +70,11 @@ function isLocalNetworkURL(url) {
70
70
mousePosition . y = event . pageY ;
71
71
} ) ;
72
72
73
+ window . addEventListener ( 'beforeunload' , ( event ) => {
74
+ //terminate the websocket before leaving the page
75
+ terminatePreviousWebSocket ( ) ;
76
+ } ) ;
77
+
73
78
var previousDistanceToBoundaryX = document . documentElement . scrollLeft ;
74
79
var previousDistanceToBoundaryY = document . documentElement . scrollTop ;
75
80
window . addEventListener ( 'scroll' , ( event ) => {
@@ -164,14 +169,14 @@ function isLocalNetworkURL(url) {
164
169
}
165
170
166
171
const addClient = ( id , skinId ) => {
167
- console . log ( "contentScript.js: addClient: adding client with id: " + id + " and skinId: " + skinId ) ;
172
+ // console.log("contentScript.js: addClient: adding client with id: " + id + " and skinId: " + skinId);
168
173
169
174
cursorUserCounter ++ ;
170
175
171
176
//create a new cursor element
172
177
var cursor = document . createElement ( "img" ) ;
173
178
cursor . id = id ;
174
- cursor . className = "cursor " ;
179
+ cursor . className = "CursorConnectUniqueCSSClass " ;
175
180
176
181
try {
177
182
cursor . src = browser . runtime . getURL ( "customization/cursors/" + skinId + ".png" ) ;
@@ -236,17 +241,16 @@ function isLocalNetworkURL(url) {
236
241
cursor . style . animation = '' ;
237
242
} ;
238
243
239
-
240
244
const injectCSS = ( ) => {
241
- var alreadyInjected = document . getElementById ( "multiCursorStyle " ) ;
245
+ var alreadyInjected = document . getElementById ( "CursorConnectUniqueCSSStyle " ) ;
242
246
243
247
if ( ! alreadyInjected ) {
244
248
//create a new style element
245
249
var style = document . createElement ( "style" ) ;
246
- style . id = "multiCursorStyle " ;
250
+ style . id = "CursorConnectUniqueCSSStyle " ;
247
251
//set the style element content
248
252
style . innerHTML = `
249
- .cursor {
253
+ .CursorConnectUniqueCSSClass {
250
254
position: absolute;
251
255
transform: translate(-33%, -23%);
252
256
left: -2000px;
@@ -271,12 +275,11 @@ function isLocalNetworkURL(url) {
271
275
272
276
document . head . appendChild ( style ) ;
273
277
274
- console . log ( "cursorConnect: injected css into: " + URL ) ;
278
+ // console.log("cursorConnect: injected css into: " + URL);
275
279
}
276
280
}
277
281
278
- terminatePreviousWebSocket ( ) ;
279
- console . log ( "cursors: contentScript.js: readyState: " + document . readyState ) ;
282
+ //console.log("cursors: contentScript.js: readyState: " + document.readyState);
280
283
if ( document . readyState == "complete" ) {
281
284
injectCSS ( ) ;
282
285
connectToWebSocket ( ) ;
@@ -290,7 +293,7 @@ function isLocalNetworkURL(url) {
290
293
setInterval ( function ( ) {
291
294
if ( window . location . toString ( ) != URL ) {
292
295
URL = window . location . toString ( ) ;
293
- console . log ( "cursors : contentScript.js: URL changed to: " + URL ) ;
296
+ // console.log("cursorConnect : contentScript.js: URL changed to: " + URL);
294
297
terminatePreviousWebSocket ( ) ;
295
298
injectCSS ( ) ;
296
299
connectToWebSocket ( ) ;
0 commit comments