"],
26 | "css": ["style.css"],
27 | "js": ["aligner.js"],
28 | "run_at": "document_end"
29 | }
30 | ],
31 | "permissions": ["activeTab"]
32 | }
33 |
--------------------------------------------------------------------------------
/src/popup.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Page Aligner
6 |
7 |
78 |
79 |
80 |
81 |
91 |
100 |
101 |
102 |
103 |
104 |
118 |
124 |
138 |
144 |
158 |
159 |
160 |
161 |
--------------------------------------------------------------------------------
/src/popup.js:
--------------------------------------------------------------------------------
1 | //
2 | //
3 | document.addEventListener('DOMContentLoaded', function () {
4 | var increaseButton = document.getElementById('centerPagesIncrease');
5 | var decreaseButton = document.getElementById('centerPagesDecrease');
6 |
7 | increaseButton.addEventListener('click', function () {
8 | chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
9 | chrome.tabs.sendMessage(tabs[0].id, { changePadding: "increase" }, function () {
10 | if (chrome.runtime.lastError) { // This check will suppress the "Unchecked lastError value ..." msg.
11 | return
12 | }
13 | });
14 | });
15 | }, false);
16 |
17 | decreaseButton.addEventListener('click', function () {
18 | chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
19 | chrome.tabs.sendMessage(tabs[0].id, { changePadding: "decrease" }, function () {
20 | if (chrome.runtime.lastError) { // This check will suppress the "Unchecked lastError value ..." msg.
21 | return
22 | }
23 | });
24 | });
25 | }, false);
26 |
27 | // check radio box
28 | var radioBoxes = document.querySelectorAll("input[name='centerPagesAlign']");
29 | chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
30 | if (tabs.length === 0) {
31 | return;
32 | }
33 | chrome.tabs.sendMessage(tabs[0].id, { query: true }, function (response) {
34 | if (chrome.runtime.lastError) { // This check will suppress the "Unchecked lastError value ..." msg.
35 | return
36 | }
37 | for (var i = 0; i < radioBoxes.length; ++i) {
38 | if (radioBoxes[i].value === response.align) {
39 | radioBoxes[i].checked = true;
40 | break;
41 | }
42 | }
43 | });
44 | });
45 |
46 | // radio box click event
47 | for (var i = 0; i < radioBoxes.length; ++i) {
48 | radioBoxes[i].addEventListener('change', function (event) {
49 | chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
50 | chrome.tabs.sendMessage(tabs[0].id, { changeAlign: event.target.value }, function () {
51 | if (chrome.runtime.lastError) { // This check will suppress the "Unchecked lastError value ..." msg.
52 | return
53 | }
54 | });
55 | });
56 | }, false);
57 | }
58 |
59 | }, false);
60 |
--------------------------------------------------------------------------------
/src/style.css:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------