mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 20:17:05 +03:00
Add auto-config import to clickbait extension, move more funcs to shared lib
Also fix a isSafari call
This commit is contained in:
@@ -1,48 +1,5 @@
|
||||
import Config from "../config";
|
||||
import { Keybind } from "../types";
|
||||
|
||||
export function showDonationLink(): boolean {
|
||||
return navigator.vendor !== "Apple Computer, Inc." && Config.config.showDonationLink;
|
||||
}
|
||||
|
||||
export function isSafari(): boolean {
|
||||
return typeof(navigator) !== "undefined" && navigator.vendor === "Apple Computer, Inc.";
|
||||
}
|
||||
|
||||
export function keybindEquals(first: Keybind, second: Keybind): boolean {
|
||||
if (first == null || second == null ||
|
||||
Boolean(first.alt) != Boolean(second.alt) || Boolean(first.ctrl) != Boolean(second.ctrl) || Boolean(first.shift) != Boolean(second.shift) ||
|
||||
first.key == null && first.code == null || second.key == null && second.code == null)
|
||||
return false;
|
||||
if (first.code != null && second.code != null)
|
||||
return first.code === second.code;
|
||||
if (first.key != null && second.key != null)
|
||||
return first.key.toUpperCase() === second.key.toUpperCase();
|
||||
return false;
|
||||
}
|
||||
|
||||
export function formatKey(key: string): string {
|
||||
if (key == null)
|
||||
return "";
|
||||
else if (key == " ")
|
||||
return "Space";
|
||||
else if (key.length == 1)
|
||||
return key.toUpperCase();
|
||||
else
|
||||
return key;
|
||||
}
|
||||
|
||||
export function keybindToString(keybind: Keybind): string {
|
||||
if (keybind == null || keybind.key == null)
|
||||
return "";
|
||||
|
||||
let ret = "";
|
||||
if (keybind.ctrl)
|
||||
ret += "Ctrl+";
|
||||
if (keybind.alt)
|
||||
ret += "Alt+";
|
||||
if (keybind.shift)
|
||||
ret += "Shift+";
|
||||
|
||||
return ret += formatKey(keybind.key);
|
||||
}
|
||||
Reference in New Issue
Block a user