mirror of
https://github.com/S2-/ping.git
synced 2025-08-02 12:20:05 +02:00
initial draft
This commit is contained in:
14
.editorconfig
Normal file
14
.editorconfig
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Editor configuration, see http://editorconfig.org
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
end_of_line = lf
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
max_line_length = off
|
||||||
|
trim_trailing_whitespace = false
|
4
.eslintignore
Normal file
4
.eslintignore
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
node_modules
|
||||||
|
thirdparty
|
||||||
|
app/*
|
||||||
|
!app/js
|
36
.eslintrc.json
Normal file
36
.eslintrc.json
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{"parserOptions":
|
||||||
|
{
|
||||||
|
"ecmaVersion": 6,
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"quotes": [2, "single", {"allowTemplateLiterals": true}],
|
||||||
|
"curly": [2, "all"],
|
||||||
|
"keyword-spacing": [2, {"overrides": {"else": {"before": true}, "catch": {"before": true, "after": false}}}],
|
||||||
|
"space-before-blocks": [2, "always"],
|
||||||
|
"wrap-iife": [2, "inside"],
|
||||||
|
"space-before-function-paren": [2, "never"],
|
||||||
|
"one-var": [2, "never"],
|
||||||
|
"vars-on-top": 0, "no-empty": [2, {"allowEmptyCatch": true}],
|
||||||
|
"array-bracket-spacing": [2, "never"],
|
||||||
|
"space-in-parens": [2, "never"],
|
||||||
|
"no-underscore-dangle": 0,
|
||||||
|
"comma-style": [2, "last"],
|
||||||
|
"comma-spacing": [2, {"before": false, "after": true}],
|
||||||
|
"space-unary-ops": [2, {"words": false, "nonwords": false}],
|
||||||
|
"no-multi-spaces": 2,
|
||||||
|
"space-infix-ops": 2,
|
||||||
|
"no-with": 2,
|
||||||
|
"indent": [2, "tab", {"SwitchCase": 1, "FunctionExpression": {"body": 1, "parameters": 1}, "MemberExpression": 0}],
|
||||||
|
"no-mixed-spaces-and-tabs": 2,
|
||||||
|
"no-trailing-spaces": 2,
|
||||||
|
"comma-dangle": [2, "never"],
|
||||||
|
"semi": [2, "always"],
|
||||||
|
"brace-style": [2, "1tbs", {"allowSingleLine": true}],
|
||||||
|
"eol-last": 2,
|
||||||
|
"dot-notation": 0,
|
||||||
|
"no-multi-str": 2,
|
||||||
|
"key-spacing": [2, {"afterColon": true}],
|
||||||
|
"func-call-spacing": [2, "never"]
|
||||||
|
}
|
||||||
|
}
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/.project
|
20
README.md
Normal file
20
README.md
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# ping
|
||||||
|
|
||||||
|
## What it does
|
||||||
|
|
||||||
|
A firefox addon that pings a server you configure, and shows an icon for up status, and a different icon for down status.
|
||||||
|
|
||||||
|
## install
|
||||||
|
|
||||||
|
On amo!
|
||||||
|
[https://addons.mozilla.org/firefox/addon/ping/](https://addons.mozilla.org/firefox/addon/ping/)
|
||||||
|
|
||||||
|
|
||||||
|
## develop
|
||||||
|
|
||||||
|
Clone this repo, open firefox on [about:debugging](about:debugging) and load the extension by selecting the cloned folder.
|
||||||
|
Start coding!
|
||||||
|
|
||||||
|
## make a release
|
||||||
|
|
||||||
|
zip the src folder and upload to https://addons.mozilla.org/
|
7
src/background-page.html
Normal file
7
src/background-page.html
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<script type="module" src="background-pinger.js"></script>
|
||||||
|
</head>
|
||||||
|
</html>
|
34
src/background-pinger.js
Normal file
34
src/background-pinger.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import { loadOptions } from './utils.js';
|
||||||
|
|
||||||
|
let options = {};
|
||||||
|
|
||||||
|
function ping(server) {
|
||||||
|
console.log('pinging ' + server);
|
||||||
|
}
|
||||||
|
|
||||||
|
function reloadConfig() {
|
||||||
|
loadOptions().then((savedOptions) => {
|
||||||
|
options.server = savedOptions.server;
|
||||||
|
options.interval = savedOptions.interval;
|
||||||
|
|
||||||
|
if (options.server && options.interval >= 1) {
|
||||||
|
ping(options.server);
|
||||||
|
|
||||||
|
if (options.pinger) {
|
||||||
|
clearInterval(options.pinger);
|
||||||
|
}
|
||||||
|
options.pinger = setInterval(function() {
|
||||||
|
ping(options.server);
|
||||||
|
}, options.interval * 1000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
browser.runtime.onMessage.addListener(function(request, sender, sendResponse) {
|
||||||
|
if (request === 'configChanged') {
|
||||||
|
reloadConfig();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//startup
|
||||||
|
reloadConfig();
|
BIN
src/icons/available-32.png
Normal file
BIN
src/icons/available-32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
BIN
src/icons/available-48.png
Normal file
BIN
src/icons/available-48.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
BIN
src/icons/available.png
Normal file
BIN
src/icons/available.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
BIN
src/icons/offline-32.png
Normal file
BIN
src/icons/offline-32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
BIN
src/icons/offline-48.png
Normal file
BIN
src/icons/offline-48.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.6 KiB |
BIN
src/icons/offline.png
Normal file
BIN
src/icons/offline.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
33
src/manifest.json
Normal file
33
src/manifest.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"description": "Just a toolbar button that shows if a server is up or not.",
|
||||||
|
"manifest_version": 2,
|
||||||
|
"name": "ping",
|
||||||
|
"version": "1.1.23",
|
||||||
|
"homepage_url": "https://github.com/S2-/ping",
|
||||||
|
"applications": {
|
||||||
|
"gecko": {
|
||||||
|
"id": "{46b66c4d-605f-4f4d-8689-20b44b45656c}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"icons": {
|
||||||
|
"48": "icons/offline-48.png"
|
||||||
|
},
|
||||||
|
"browser_action": {
|
||||||
|
"default_icon": "icons/offline-32.png",
|
||||||
|
"theme_icons": [{
|
||||||
|
"light": "icons/offline-32-light.png",
|
||||||
|
"dark": "icons/offline-32.png",
|
||||||
|
"size": 32
|
||||||
|
}],
|
||||||
|
"default_title": "ping",
|
||||||
|
"default_popup": "popup/ping.html"
|
||||||
|
},
|
||||||
|
"background": {
|
||||||
|
"page": "background-page.html"
|
||||||
|
},
|
||||||
|
"permissions": [
|
||||||
|
"storage",
|
||||||
|
"<all_urls>",
|
||||||
|
"webRequest"
|
||||||
|
]
|
||||||
|
}
|
74
src/popup/ping.css
Normal file
74
src/popup/ping.css
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
body {
|
||||||
|
margin: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div {
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="number"] {
|
||||||
|
-moz-appearance: none;
|
||||||
|
color: var(--in-content-text-color);
|
||||||
|
border: 1px solid var(--in-content-box-border-color);
|
||||||
|
-moz-border-top-colors: none !important;
|
||||||
|
-moz-border-right-colors: none !important;
|
||||||
|
-moz-border-bottom-colors: none !important;
|
||||||
|
-moz-border-left-colors: none !important;
|
||||||
|
border-radius: 2px;
|
||||||
|
background-color: var(--in-content-box-background);
|
||||||
|
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
padding: 5px 10px;
|
||||||
|
|
||||||
|
width: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#length-min {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="checkbox"] {
|
||||||
|
margin-bottom: -7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pw {
|
||||||
|
border: 2px black solid;
|
||||||
|
width: 250px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#copy {
|
||||||
|
margin-left: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#exclude {
|
||||||
|
width: 183px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copied {
|
||||||
|
pointer-events: none;
|
||||||
|
height: 26px;
|
||||||
|
width: 100%;
|
||||||
|
background-color: #FFF8DC;
|
||||||
|
position: absolute;
|
||||||
|
padding-right: 0;
|
||||||
|
padding-left: 0;
|
||||||
|
padding-top: 5px;
|
||||||
|
padding-bottom: 5px;
|
||||||
|
text-align: center;
|
||||||
|
margin-right: -15px;
|
||||||
|
margin-left: -19px;
|
||||||
|
margin-top: -27px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fadein {
|
||||||
|
visibility: visible;
|
||||||
|
opacity: 1;
|
||||||
|
transition: opacity 1s linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fadeout {
|
||||||
|
visibility: hidden;
|
||||||
|
opacity: 0;
|
||||||
|
transition: visibility 0s 1s, opacity 1s linear;
|
||||||
|
}
|
27
src/popup/ping.html
Normal file
27
src/popup/ping.html
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="chrome://global/skin/global.css" type="text/css" />
|
||||||
|
<link rel="stylesheet" href="chrome://global/skin/in-content/common.css" type="text/css" />
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="ping.css"/>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<form>
|
||||||
|
<div>
|
||||||
|
<label for="server">Server: </label>
|
||||||
|
<input type="text" id="server" name="server">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="interval">Interval in seconds: </label>
|
||||||
|
<input type="text" id="interval" name="interval">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<script type="module" src="ping.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
26
src/popup/ping.js
Normal file
26
src/popup/ping.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { loadOptions, saveOptions } from '../utils.js';
|
||||||
|
|
||||||
|
function getParams() {
|
||||||
|
return {
|
||||||
|
server: document.getElementById('server').value,
|
||||||
|
interval: parseInt(document.getElementById('interval').value)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
var list = document.getElementsByTagName('input');
|
||||||
|
for (var i = 0; i < list.length; i++) {
|
||||||
|
list[i].addEventListener('change', (ev) => {
|
||||||
|
saveOptions(getParams());
|
||||||
|
browser.runtime.sendMessage('configChanged');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
loadOptions().then((options) => {
|
||||||
|
document.getElementById('server').value = options.server;
|
||||||
|
document.getElementById('interval').value = options.interval;
|
||||||
|
|
||||||
|
browser.runtime.sendMessage('configChanged');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
19
src/utils.js
Normal file
19
src/utils.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
function loadOptions() {
|
||||||
|
return browser.storage.local.get({
|
||||||
|
server: '',
|
||||||
|
interval: 60
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function saveOptions(options) {
|
||||||
|
return browser.storage.local.set(options);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof(window['ping'] === 'undefined')) {
|
||||||
|
window.ping = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
loadOptions,
|
||||||
|
saveOptions
|
||||||
|
};
|
Reference in New Issue
Block a user