summaryrefslogtreecommitdiffstats
path: root/bcma/mydata.js
blob: af1c5fbe58a59bbc56b2d634291f173ae5ffef8c (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
function onError(e) {
	console.log(`Error:${e}`);
}

document.addEventListener('DOMContentLoaded', function () {
	browser.runtime.sendMessage(['cf']).then(function (r) {
		if (r[0] == 'ok') {
			document.getElementById('t').value = JSON.parse(r[1]).join("\n");
			document.getElementById('g').value = JSON.parse(r[2]).join("\n");
			if (r[3]) {
				document.getElementById('bi0').checked = true;
				document.getElementById('bi1').checked = false;
			} else {
				document.getElementById('bi0').checked = false;
				document.getElementById('bi1').checked = true;
			}
			switch (r[4]) {
				case 1:
					document.getElementById('ta0').checked = false;
					document.getElementById('ta1').checked = true;
					document.getElementById('ta2').checked = false;
					document.getElementById('ta3').checked = false;
					break;
				case 2:
					document.getElementById('ta0').checked = false;
					document.getElementById('ta1').checked = false;
					document.getElementById('ta2').checked = true;
					document.getElementById('ta3').checked = false;
					break;
				case 3:
					document.getElementById('ta0').checked = false;
					document.getElementById('ta1').checked = false;
					document.getElementById('ta2').checked = false;
					document.getElementById('ta3').checked = true;
					break;
				default:
					document.getElementById('ta0').checked = true;
					document.getElementById('ta1').checked = false;
					document.getElementById('ta2').checked = false;
					document.getElementById('ta3').checked = false;
					break;
			}
			document.body.style.display = 'block';
			document.addEventListener('contextmenu', function (z) {
				if (z.target.tagName != 'TEXTAREA') {
					z.preventDefault();
				}
			});
		} else {
			document.getElementById('t').value = '!!! LOAD ERROR !!!';
			document.getElementById('g').value = '!!! LOAD ERROR !!!';
		}
	}, onError);
});

document.getElementById('exp').addEventListener('click', function () {
	browser.tabs.create({
		active: true,
		url: 'about:blank'
	}).then(function (t) {
		browser.tabs.executeScript(t.id, {
			matchAboutBlank: true,
			code: "document.documentElement.innerHTML='<html><head><title>Data</title></head><body><pre>'+atob('" + btoa(document.getElementById('t').value) + "')+'</pre></body></html>';window.stop();"
		}).then(function (e) {}, onError);
	}, onError);
});

document.getElementById('clr').addEventListener('click', function () {
	browser.runtime.sendMessage(['erosman']).then(function (r) {
		document.getElementById('t').value = '';
	}, onError);
});
document.getElementById('bi0').addEventListener('click', function () {
	if (this.checked) {
		browser.runtime.sendMessage(['bi', 'y']).then(function (r) {}, onError);
	}
});
document.getElementById('bi1').addEventListener('click', function () {
	if (this.checked) {
		browser.runtime.sendMessage(['bi', 'n']).then(function (r) {}, onError);
	}
});
document.getElementById('ta0').addEventListener('click', function () {
	if (this.checked) {
		browser.runtime.sendMessage(['ta', '0']).then(function (r) {}, onError);
	}
});
document.getElementById('ta1').addEventListener('click', function () {
	if (this.checked) {
		browser.runtime.sendMessage(['ta', '1']).then(function (r) {}, onError);
	}
});
document.getElementById('ta2').addEventListener('click', function () {
	if (this.checked) {
		browser.runtime.sendMessage(['ta', '2']).then(function (r) {}, onError);
	}
});
document.getElementById('ta3').addEventListener('click', function () {
	if (this.checked) {
		browser.runtime.sendMessage(['ta', '3']).then(function (r) {}, onError);
	}
});
document.getElementById('ign').addEventListener('click', function () {
	browser.runtime.sendMessage(['ig', document.getElementById('g').value.split("\n")]).then(function (r) {}, onError);
});