├── .gitignore ├── LICENCE.md ├── buttons ├── favicon-16.png ├── favicon-32.png └── favicon-64.png ├── icon.png ├── images ├── icon_128.png ├── icon_16.png ├── icon_48.png └── mega │ ├── loading-sprite_v4.png │ ├── loading-sprite_v4@2x.png │ ├── new-startpage-sprite_v5.png │ └── new-startpage-sprite_v5@2x.png ├── manifest.json └── mega.js /.gitignore: -------------------------------------------------------------------------------- 1 | /nbproject/ 2 | /.vs/ 3 | *.sqlite 4 | *.suo 5 | -------------------------------------------------------------------------------- /LICENCE.md: -------------------------------------------------------------------------------- 1 | MEGA LIMITED CODE REVIEW LICENCE 2 | ================================ 3 | 4 | This licence grants you the rights, and only the rights, set out 5 | below, to access and review Mega's code. If you take advantage of 6 | these rights, you accept this licence. If you do not accept the 7 | licence, do not access the code. 8 | 9 | Words used in the Mega Limited Terms of Service 10 | [https://mega.nz/#terms] have the same meaning in this licence. Where 11 | there is any inconsistency between this licence and those Terms of 12 | Service, these terms prevail. 13 | 14 | 15 | Section 1 -- Definitions 16 | ------------------------ 17 | 18 | - "code" means the Mega code made available from time, in our sole 19 | discretion, for access under this licence at [https://github.com/]. 20 | Reference to code in this licence means the code and any part of it 21 | and any derivative of it. 22 | 23 | - "defect" means a defect, bug, backdoor, security issue or other 24 | deficiency in the code. 25 | 26 | - "review " means to access, analyse, test and otherwise review the 27 | code as a reference, for the sole purpose of analysing it for 28 | defects. 29 | 30 | - "you" means the licensee of rights set out in this licence. 31 | 32 | 33 | Section 2 -- Grant of Rights 34 | ---------------------------- 35 | 36 | 1. Subject to the terms of this licence, we grant you a 37 | non-transferable, non-exclusive, worldwide, royalty-free licence to 38 | access and use the code solely for review purposes. 39 | 40 | 2. You may provide the code to anyone else and publish excerpts of it 41 | for the purposes of review and commentary, provided that when you 42 | do so you make any recipient of the code aware of the terms of this 43 | licence and that you attribute the code to Mega. 44 | 45 | 3. Other than in respect of those parts of the code that were 46 | developed by other parties and as specified strictly in accordance 47 | with the open source and other licences under which those parts of 48 | the code have been made available, as set out on our website or in 49 | those items of code, you are not entitled to use or do anything 50 | with the code for any commercial or other purpose, other than 51 | review and commentary on it. 52 | 53 | 4. Subject to the terms of this licence, you must at all times comply 54 | with and shall be bound by our Terms of Use 55 | [https://mega.nz/#terms], Privacy Policy [https://mega.nz/#privacy] 56 | and Takedown Guidance Policy [https://mega.nz/#takedown]. 57 | 58 | 59 | Section 3 -- Limitations 60 | ------------------------ 61 | 62 | 1. This licence does not grant you any rights to use Mega's name, 63 | logo, or trademarks and you must not in any way indicate you are 64 | authorised to speak on behalf of Mega. 65 | 66 | 2. If you issue proceedings in any jurisdiction against Mega because 67 | you consider Mega has infringed copyright or any patent right in 68 | respect of the code (including any joinder or counterclaim), your 69 | licence to the code is automatically terminated. 70 | 71 | 3. THE CODE IS MADE AVAILABLE "AS-IS" AND WITHOUT ANY EXPRESS OF 72 | IMPLIED GUARANTEES AS TO FITNESS, MERCHANTABILITY, NON-INFRINGEMENT 73 | OR OTHERWISE. IT IS NOT BEING PROVIDED IN TRADE BUT ON A VOLUNTARY 74 | BASIS ON OUR PART AND YOURS AND IS NOT MADE AVAILABE FOR CONSUMER 75 | USE OR ANY OTHER USE OUTSIDE THE TERMS OF THIS LICENCE. ANYONE 76 | ACCESSING THE CODE SHOULD HAVE THE REQUISITE EXPERTISE TO SECURE 77 | THEIR OWN SYSTEM AND DEVICES AND TO ACCESS AND USE THE CODE FOR 78 | REVIEW PURPOSES. YOU BEAR THE RISK OF ACCESSING AND USING IT. IN 79 | PARTICULAR, MEGA BEARS NO LIABILITY FOR ANY INTERFERENCE WITH OR 80 | ADVERSE EFFECT ON YOUR SYSTEM OR DEVICES AS A RESULT OF YOUR 81 | ACCESSING AND USING THE CODE. 82 | 83 | 84 | Section 4 -- Termination, suspension and variation 85 | -------------------------------------------------- 86 | 87 | 1. We may suspend, terminate or vary the terms of this licence and any 88 | access to the code at any time, without notice, for any reason or 89 | no reason, in respect of any licensee, group of licensees or all 90 | licensees. 91 | 92 | 93 | Section 5 -- General 94 | -------------------- 95 | 96 | 1. This licence and its interpretation and operation are governed 97 | solely by New Zealand law. We and each you submit to the exclusive 98 | jurisdiction of the New Zealand arbitral tribunals as further 99 | described in our Terms of Service and you agree not to raise any 100 | jurisdictional issue if we need to enforce an arbitral award or 101 | judgment in New Zealand or another country. 102 | 103 | 2. Questions and comments regarding this licence are welcomed and 104 | should be addressed to [support@mega.nz]. 105 | 106 | 107 | Last updated 20 January 2016. -------------------------------------------------------------------------------- /buttons/favicon-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meganz/firefox-web-extension/0045d2be706cd16764689f80af98508e92d2ee86/buttons/favicon-16.png -------------------------------------------------------------------------------- /buttons/favicon-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meganz/firefox-web-extension/0045d2be706cd16764689f80af98508e92d2ee86/buttons/favicon-32.png -------------------------------------------------------------------------------- /buttons/favicon-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meganz/firefox-web-extension/0045d2be706cd16764689f80af98508e92d2ee86/buttons/favicon-64.png -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meganz/firefox-web-extension/0045d2be706cd16764689f80af98508e92d2ee86/icon.png -------------------------------------------------------------------------------- /images/icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meganz/firefox-web-extension/0045d2be706cd16764689f80af98508e92d2ee86/images/icon_128.png -------------------------------------------------------------------------------- /images/icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meganz/firefox-web-extension/0045d2be706cd16764689f80af98508e92d2ee86/images/icon_16.png -------------------------------------------------------------------------------- /images/icon_48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meganz/firefox-web-extension/0045d2be706cd16764689f80af98508e92d2ee86/images/icon_48.png -------------------------------------------------------------------------------- /images/mega/loading-sprite_v4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meganz/firefox-web-extension/0045d2be706cd16764689f80af98508e92d2ee86/images/mega/loading-sprite_v4.png -------------------------------------------------------------------------------- /images/mega/loading-sprite_v4@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meganz/firefox-web-extension/0045d2be706cd16764689f80af98508e92d2ee86/images/mega/loading-sprite_v4@2x.png -------------------------------------------------------------------------------- /images/mega/new-startpage-sprite_v5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meganz/firefox-web-extension/0045d2be706cd16764689f80af98508e92d2ee86/images/mega/new-startpage-sprite_v5.png -------------------------------------------------------------------------------- /images/mega/new-startpage-sprite_v5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meganz/firefox-web-extension/0045d2be706cd16764689f80af98508e92d2ee86/images/mega/new-startpage-sprite_v5@2x.png -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "MEGA", 4 | "description": "Secure Cloud Storage and Chat", 5 | "version": "1.0.0", 6 | "content_security_policy": "script-src 'self' https://*.mega.co.nz https://*.mega.nz blob:; object-src 'self' https://*.mega.co.nz https://*.mega.nz;", 7 | "permissions": [ 8 | "clipboardWrite", 9 | "unlimitedStorage", 10 | "https://mega.co.nz/", 11 | "https://mega.nz/", 12 | "wss://mega.nz/", 13 | "webRequest", 14 | "webRequestBlocking" 15 | ], 16 | "web_accessible_resources": ["mega/secure.html"], 17 | "homepage_url": "https://mega.nz/", 18 | "background": { 19 | "scripts": ["mega.js"] 20 | }, 21 | "icons": { 22 | "16": "images/icon_16.png", 23 | "48": "images/icon_48.png", 24 | "128": "images/icon_128.png" 25 | }, 26 | "browser_action": { 27 | "default_icon": { 28 | "16": "buttons/favicon-16.png", 29 | "32": "buttons/favicon-32.png", 30 | "64": "buttons/favicon-64.png" 31 | }, 32 | "default_title": "MEGA" 33 | }, 34 | "applications": { 35 | "gecko": { 36 | "id": "firefox@mega.co.nz", 37 | "strict_min_version": "52.0", 38 | "update_url": "https://mega.nz/firefox-web-extension-updates.json" 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /mega.js: -------------------------------------------------------------------------------- 1 | // Add a listener for clicks on the Mega toolbar icon 2 | browser.browserAction.onClicked.addListener(openMyPage); 3 | 4 | /** 5 | * Open a new tab and load the Mega homepage in it 6 | */ 7 | function openMyPage() { 8 | browser.tabs.create({ 9 | url: '/mega/secure.html' 10 | }); 11 | } 12 | 13 | chrome.webRequest.onBeforeRequest.addListener(function(details) { 14 | if ((details.url.substr(-4) === '.xml') 15 | || (details.url.substr(-4) === '.crx') 16 | || (details.url.substr(-4) === '.xpi') 17 | || (details.url.substr(-4) === '.exe') 18 | || (details.url.substr(-4) === '.dmg') 19 | || (details.url.substr(-3) === '.gz') 20 | || (details.url.substr(-4) === '.deb') 21 | || (details.url.substr(-4) === '.rpm') 22 | || (details.url.substr(-4) === '.zip') 23 | || (details.url.substr(-4) === '.txt') 24 | || (details.url.substr(-4) === '.pdf') 25 | || (details.url.substr(-3) === '.js') 26 | || (details.url.indexOf('mega.nz/linux') > -1)) { 27 | 28 | return { 29 | cancel: false 30 | }; 31 | } 32 | else { 33 | var hash = ''; 34 | if (details.url.indexOf('://mega.nz/') > 0) { 35 | var url = details.url; 36 | var path = url.split('.nz/')[1]; 37 | 38 | if (url.indexOf('#') > -1) { 39 | var nlfe = url.match(/\/\/mega\.nz\/(embed|drop)[!#/]+([\w-]{8,11})(?:[#!](.*))?/); 40 | 41 | if (nlfe) { 42 | var type = nlfe[1]; 43 | var node = nlfe[2]; 44 | var pkey = nlfe[3]; 45 | var lpfx = ({embed: 'E', drop: 'D'})[type] || ''; 46 | 47 | hash = '#' + lpfx + '!' + node + (pkey ? '!' + pkey : ''); 48 | } 49 | else if (url.indexOf('://mega.nz/chat/') > -1) { 50 | hash = '#' + path; 51 | } 52 | else if (url.indexOf('/folder/') > -1 || url.indexOf('/file/') > -1) { 53 | var uri = new URL(url); 54 | hash = '#' + uri.pathname + uri.hash; 55 | } 56 | else { 57 | hash = '#' + url.split('#')[1]; 58 | } 59 | } 60 | else if (path) { 61 | hash = '#' + path; 62 | } 63 | } 64 | return { redirectUrl: chrome.extension.getURL("mega/secure.html" + hash) }; 65 | } 66 | }, 67 | { 68 | urls: [ 69 | 'http://mega.co.nz/*', 70 | 'https://mega.co.nz/*', 71 | 'http://www.mega.co.nz/*', 72 | 'https://www.mega.co.nz/*', 73 | 'http://mega.nz/*', 74 | 'https://mega.nz/*', 75 | 'http://www.mega.nz/*', 76 | 'https://www.mega.nz/*' 77 | ], 78 | types: ['main_frame', 'sub_frame'] 79 | }, 80 | ['blocking'] 81 | ); 82 | 83 | chrome.webRequest.onHeadersReceived.addListener(function(details) { 84 | // console.log('responseHeaders',responseHeaders); 85 | }, 86 | { 87 | urls: [ 88 | chrome.extension.getURL('mega') 89 | ], 90 | types: ['main_frame', 'sub_frame'] 91 | }, 92 | ['blocking'] 93 | ); 94 | --------------------------------------------------------------------------------