forked from meganz/webclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
e10s.js
46 lines (40 loc) · 939 Bytes
/
e10s.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
36
37
38
39
40
41
42
43
44
45
46
(function(window) {
"use strict";
const webNav = docShell.QueryInterface(Components.interfaces.nsIWebNavigation);
const _hosts = {
"mega.co.nz" : 1,
"mega.is" : 1,
"mega.io" : 1,
"mega.nz" : 1,
"me.ga" : 1
};
var mID = String(Components.stack.filename).split("=").pop();
addMessageListener("MEGA:"+mID+":bcast", m =>
{
m = m.data.split(':');
if (mID === m[1] && m[2]+m[0] === 'da')
{
mID = 0;
}
});
addEventListener("DOMContentLoaded", ev =>
{
var doc = ev.originalTarget;
if (mID && doc.nodeName === "#document")
{
var l = doc.location;
if ((l.protocol === 'https:' || l.protocol === 'http:') && _hosts[l.host] && l.pathname === '/')
{
l = 'mega:' + (l.hash ? l.hash : '');
try
{
webNav.loadURI(l,0x80,null,null,null);
}
catch(e)
{
if (e.result === 0x804b0012) sendSyncMessage('MEGA:'+mID+':loadURI', l);
}
}
}
});
})(content);