Skip to content

Commit 2e4e231

Browse files
committed
Added button to open shortcut settings.
1 parent 8ecf0cd commit 2e4e231

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

content_script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function check() {
176176

177177
if (CAPTCHA) {
178178
if (button) {
179-
button = button.shadowRoot.querySelector("md-text-button").shadowRoot.getElementById("button");
179+
button = button.shadowRoot.querySelector("mwc-button").shadowRoot.getElementById("button");
180180
console.warn("Warning: Cancel button found. Clicking button:", button.innerText);
181181
button.click();
182182
}

options/options.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<h3>Colab Autorun and Connect</h3>
5757
<p><a href="https://github.com/tdulcet/Colab-Autorun-and-Connect" target="_blank"><button type="button">ℹ️
5858
Information</button></a>
59+
<button type="button" id="shortcut">⌨️ Shortcut Settings</button>
5960
<a href="https://www.tealdulcet.com/" target="_blank"><button type="button">❤️ Donate</button></a>
6061
</p>
6162
</section>

options/options.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@ import * as AutomaticSettings from "/common/modules/AutomaticSettings/AutomaticS
99

1010
import * as CustomOptionTriggers from "./modules/CustomOptionTriggers.js";
1111

12+
// Chrome
13+
// Adapted from: https://github.com/mozilla/webextension-polyfill/blob/master/src/browser-polyfill.js
14+
const IS_CHROME = Object.getPrototypeOf(browser) !== Object.prototype;
15+
16+
document.getElementById("shortcut").addEventListener("click", (event) => {
17+
event.target.disabled = true;
18+
19+
if (browser.commands.openShortcutSettings) {
20+
browser.commands.openShortcutSettings().finally(() => {
21+
event.target.disabled = false;
22+
});
23+
} else if (IS_CHROME) {
24+
browser.tabs.create({ url: "chrome://extensions/shortcuts" }).finally(() => {
25+
event.target.disabled = false;
26+
});
27+
}
28+
});
29+
1230
// init modules
1331
CustomOptionTriggers.registerTrigger();
1432
AutomaticSettings.setDefaultOptionProvider(AddonSettings.getDefaultValue);

popup.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,22 @@ const stopwatch = document.getElementById("stopwatch");
2626
*/
2727
function outputduration(sec) {
2828
// console.log(sec);
29-
const d = Math.floor(sec / 86400);
30-
const h = Math.floor(sec % 86400 / 3600);
31-
const m = Math.floor(sec % 3600 / 60);
32-
const s = sec % 60;
29+
const days = Math.floor(sec / 86400);
30+
const hours = Math.floor(sec % 86400 / 3600);
31+
const minutes = Math.floor(sec % 3600 / 60);
32+
const seconds = sec % 60;
3333
let text = "";
34-
if (d > 0) {
35-
text += `${numberFormat1.format(d)} `;
34+
if (days > 0) {
35+
text += `${numberFormat1.format(days)} `;
3636
}
37-
if (d > 0 || h > 0) {
38-
text += `${numberFormat2.format(h)} `;
37+
if (days > 0 || hours > 0) {
38+
text += `${numberFormat2.format(hours)} `;
3939
}
40-
if (d > 0 || h > 0 || m > 0) {
41-
text += `${numberFormat3.format(m)} `;
40+
if (days > 0 || hours > 0 || minutes > 0) {
41+
text += `${numberFormat3.format(minutes)} `;
4242
}
43-
if (d > 0 || h > 0 || m > 0 || s > 0) {
44-
text += numberFormat4.format(s);
43+
if (days > 0 || hours > 0 || minutes > 0 || seconds > 0) {
44+
text += numberFormat4.format(seconds);
4545
}
4646
return text;
4747
}

0 commit comments

Comments
 (0)