-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathutil.inject.RoomViewNotifier.js
35 lines (31 loc) · 1.44 KB
/
util.inject.RoomViewNotifier.js
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
/* Posted December 3rd, 2018 by @semperrabbit*/
// Note: excessive use of client's API connection may cause devs to lock it down
global.injectRoomViewNotifier = function(){//* remove one / before this comment if things break...
if(!global.RoomViewNotifierInjected) {
global.RoomViewNotifierInjected = true;
var output = `<SPAN>Trying to inject RoomViewNotifier code!</SPAN>
<SCRIPT>
if(!window.viewNotifierInstalled) {
window.viewNotifierInstalled = true;
window.addEventListener("hashchange", function(){
const [,page,shardName,roomName] = window.location.hash.split('/')
if(page == "room") { /* ensure we are in room view... */
if(window.viewNotifierShardName !== shardName || window.viewNotifierRoomName !== roomName) {
console.log("Pushing data from viewNotifier: shard: " + shardName + " roomName: " + roomName);
window.viewNotifierShardName = shardName;
window.viewNotifierRoomName = roomName;
angular.element($('body')).injector().get('Connection').sendConsoleCommand(
"Memory.roomViews = Memory.roomViews || []; Memory.roomViews.push({shard: '" + shardName + "', room: '" + roomName + "'})");
}
} else {
console.log("not in room view");
}
}, false);
}
</SCRIPT>`
console.log(output.replace(/(\r\n|\n|\r)\t+|(\r\n|\n|\r) +|(\r\n|\n|\r)/gm, ''));
}
//*/
}
global.forceInjectRoomViewNotifier = ()=>{global.RoomViewNotifierInjected = false; injectRoomViewNotifier();}
injectRoomViewNotifier();