Skip to content

Commit

Permalink
v2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
adokseo committed Aug 3, 2022
1 parent ffb289a commit c55e55f
Show file tree
Hide file tree
Showing 8 changed files with 778 additions and 578 deletions.
460 changes: 265 additions & 195 deletions assets/satus/satus.css

Large diffs are not rendered by default.

723 changes: 402 additions & 321 deletions assets/satus/satus.js

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions content-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function isset(variable) {

function prevent(event) {
if (isset(extension.storage.website.active) === false || extension.storage.website.active === true) {
for (var key in extension.storage.website.data) {
for (var key in extension.storage.website) {
var item = extension.storage.website[key],
same_keys = true;

Expand Down Expand Up @@ -140,19 +140,13 @@ function hid_keyboard(event) {
}

if (isset(extension.storage.website.active) === false || extension.storage.website.active === true) {
console.log(extension.storage.website.search === true,
extension.hid.keys[70],
extension.hid.shift === false,
extension.hid.ctrl === true,
extension.hid.alt === false);
if (
extension.storage.website.search === true &&
extension.hid.keys[70] &&
extension.hid.shift === false &&
extension.hid.ctrl === true &&
extension.hid.alt === false
) {
console.log('aaa');
event.stopPropagation();
}
}
Expand All @@ -176,6 +170,16 @@ chrome.runtime.sendMessage('tab-connected', function (response) {
});
});

chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
var action = message.action;

if (action === 'options-page-connected') {
if (window === window.top) {
sendResponse(extension.hostname);
}
}
});

chrome.storage.onChanged.addListener(function () {
extension.storage.import(function () {
if (extension.storage.get('websites/' + extension.hostname + '/separated') === true) {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "Unlock Keyboard & Mouse",
"description": "__MSG_description__",
"version": "2.0",
"version": "2.1",
"default_locale": "en",
"icons": {
"16": "assets/icons/16.png",
Expand Down
25 changes: 23 additions & 2 deletions options-page/index.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
/*--------------------------------------------------------------
>>> OPTIONS PAGE
----------------------------------------------------------------
# Body
# Fonts
# Themes
# Alert
--------------------------------------------------------------*/

/*--------------------------------------------------------------
# BODY
--------------------------------------------------------------*/

body {
font-family: Roboto, sans-serif;
font-size: 14px;
margin: 0;
overflow: hidden
}

body[tab] {
width: 100vw;
height: 100vh
}


/*--------------------------------------------------------------
# FONTS
--------------------------------------------------------------*/
Expand Down Expand Up @@ -35,9 +53,12 @@
# THEMES
--------------------------------------------------------------*/

body {
.satus-base {
--satus-light: 0, 0, 0;
--satus-primary: #f6b465;
--satus-alert-background--error: #f2cfcf;
--satus-alert-border--error: 1px solid #e58a8a;
--satus-alert-foreground--error: #d74747;
--satus-header-background: #fff;
--satus-header-shadow: 0 0 3px rgba(var(--satus-light), .1), inset 0 -1px 0 rgba(var(--satus-light), .1);
--satus-header-foreground: #848471;
Expand All @@ -52,7 +73,7 @@ body {
--satus-tabs-foreground: #fff;
}

body[theme='dark'] {
.satus-base[theme='dark'] {
--satus-light: 255, 255, 255;
--satus-primary: #8f8f8f;
--satus-base-background: #000;
Expand Down
5 changes: 1 addition & 4 deletions options-page/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
<title>Unlock Keyboard & Mouse</title>
<style>
body {
font-family: Roboto, sans-serif;
font-size: 14px;
width: 320px;
height: 500px;
margin: 0
height: 500px
}
</style>
<link rel="stylesheet" href="../assets/satus/satus.css">
Expand Down
91 changes: 47 additions & 44 deletions options-page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,63 +25,66 @@ satus.storage.import(function (items) {
language = window.navigator.language;
}

if (items.theme === 'dark') {
document.body.setAttribute('theme', 'dark');
}

satus.locale.import(language, function () {
chrome.tabs.query({
active: true,
currentWindow: true
}, function (tabs) {
var tab = tabs[0],
url = new URL(tab.url);

extension.hostname = url.hostname;
chrome.tabs.sendMessage(tabs[0].id, {
action: 'options-page-connected'
}, function (response) {
extension.hostname = response || '';

if (
tab.url.startsWith('about:') ||
tab.url.startsWith('chrome') ||
tab.url.startsWith('edge') ||
tab.url.startsWith('https://addons.mozilla.org') ||
tab.url.startsWith('https://chrome.google.com/webstore') ||
tab.url.startsWith('https://microsoftedge.microsoft.com/addons') ||
tab.url.startsWith('moz') ||
tab.url.startsWith('view-source:') ||
tab.url.endsWith('.pdf')
) {
extension.skeleton.main.layers.toolbar = {
component: 'alert',
variant: 'error',
text: function () {
return satus.locale.get('thePageHOSTNAMEIsProtectedByBrowser').replace('HOSTNAME', url.protocol + '//' + url.hostname);
}
};
} else {
extension.skeleton.main.layers.toolbar = {
component: 'alert',
variant: 'success',
if (!response) {
extension.skeleton.main.layers.toolbar = {
component: 'alert',
variant: 'error',
text: function () {
return satus.locale.get('somethingWentWrongTryReloadingThePage');
}
};
} else if (
response.startsWith('about:') ||
response.startsWith('chrome') ||
response.startsWith('edge') ||
response.startsWith('https://addons.mozilla.org') ||
response.startsWith('https://chrome.google.com/webstore') ||
response.startsWith('https://microsoftedge.microsoft.com/addons') ||
response.startsWith('moz') ||
response.startsWith('view-source:') ||
response.endsWith('.pdf')
) {
extension.skeleton.main.layers.toolbar = {
component: 'alert',
variant: 'error',
text: function () {
return satus.locale.get('thePageHOSTNAMEisProtectedByBrowser').replace('HOSTNAME', response);
}
};
} else {
extension.skeleton.main.layers.toolbar = {
component: 'alert',
variant: 'success',

switch: {
component: 'switch',
text: url.hostname,
storage: 'websites/' + extension.hostname + '/active',
value: true
}
};
}
switch: {
component: 'switch',
text: response,
storage: 'websites/' + response + '/active',
value: true
}
};
}

satus.render(extension.skeleton);
satus.render(extension.skeleton);

extension.exportSettings();
extension.importSettings();
extension.exportSettings();
extension.importSettings();
});
});
}, '_locales/');
});

chrome.runtime.sendMessage({
action: 'options-page-connected'
}, function (response) {
chrome.runtime.sendMessage('options-page-connected', function (response) {
if (response && response.isTab) {
document.body.setAttribute('tab', '');
}
Expand Down
32 changes: 28 additions & 4 deletions options-page/skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
--------------------------------------------------------------*/

extension.skeleton = {
component: 'base'
component: 'base',
attr: {
theme: function () {
return satus.storage.get('theme') || 'light';
}
}
};


Expand Down Expand Up @@ -76,6 +81,13 @@ extension.skeleton.header = {
style: {
height: 'auto',
margin: '0 0 12px'
},
on: {
render: function () {
if (extension.hostname.length === 0) {
this.style.display = 'none';
}
}
}
},
separate: {
Expand All @@ -100,11 +112,23 @@ extension.skeleton.header = {
satus.empty(extension.skeleton.main.layers.section.rendered);

satus.render(extension.skeleton.main.layers.rendered.path[0].section, extension.skeleton.main.layers.section.rendered, undefined, true);
},
render: function () {
if (extension.hostname.length === 0) {
this.style.display = 'none';
}
}
}
},
divider: {
component: 'divider'
component: 'divider',
on: {
render: function () {
if (extension.hostname.length === 0) {
this.style.display = 'none';
}
}
}
},
theme: {
component: 'select',
Expand All @@ -126,9 +150,9 @@ extension.skeleton.header = {
on: {
change: function () {
if (this.storage.value === 'dark') {
document.body.setAttribute('theme', 'dark');
extension.skeleton.rendered.setAttribute('theme', 'dark');
} else {
document.body.removeAttribute('theme');
extension.skeleton.rendered.removeAttribute('theme');
}
}
},
Expand Down

0 comments on commit c55e55f

Please sign in to comment.