forked from p3lim/dotjs-universal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
33 lines (27 loc) · 939 Bytes
/
options.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
var path, type;
if(navigator.appVersion.match(/Chromium/))
type = 'Chromium';
else
type = 'Google/Chrome';
var system = navigator.platform;
if(system.indexOf('Win') != -1)
path = '%LOCALAPPDATA%/' + type + '/User Data';
else if(system.indexOf('Linux') != -1)
path = '~/.config/' + type.toLowerCase().replace(/\//, '-');
else if(system.indexOf('Mac') != -1)
path = '~/Library/Application Support/' + type;
path += '/Default/Extensions/' + chrome.i18n.getMessage('@@extension_id');
var xhr = new XMLHttpRequest();
xhr.open('GET', 'manifest.json');
xhr.onload = function(){
var manifest = JSON.parse(xhr.responseText);
path += '/' + manifest.version + '_0/';
if(system.indexOf('Win') != -1)
path = path.replace(/\//g, '\\');
var scripts = document.querySelector('.scripts');
scripts.value = path + 'scripts';
scripts.focus();
scripts.select();
document.querySelector('.styles').value = path + 'styles';
}
xhr.send(null);