Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor entire extension code #53

Merged
merged 31 commits into from
Oct 23, 2021
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
148c4e5
Begin react refactor
timonla Oct 3, 2021
0f50947
Switch to web component setup
timonla Oct 6, 2021
1a40f38
Improve component typing
timonla Oct 6, 2021
731f4c9
Add utility method to create web component instances
timonla Oct 7, 2021
6d82f4b
Setup eslint
timonla Oct 7, 2021
4657f79
Use strict mode
timonla Oct 7, 2021
9f280d6
Add build checks
timonla Oct 7, 2021
be7ff9b
Do missing linting
timonla Oct 7, 2021
05e6611
Only do ci checks on pull requests
timonla Oct 7, 2021
feb7d2b
Add type-check ci
timonla Oct 7, 2021
3ae7e7f
Auto generate used licenses
timonla Oct 7, 2021
eb65621
Fix eslint
timonla Oct 8, 2021
69052de
Format and remove unused functionality
timonla Oct 8, 2021
71b0031
Add extension recommendations
timonla Oct 8, 2021
0b0f009
Separate features from each other
timonla Oct 11, 2021
bf88e20
Update directory structure
timonla Oct 11, 2021
443a7ec
Fix spacing
timonla Oct 22, 2021
04ff9b5
Rename snippet file
timonla Oct 22, 2021
423b801
Simplify additional player info rendering
timonla Oct 22, 2021
0971730
Fix grammar
timonla Oct 22, 2021
8c94c66
Update type to always return a PlayerInfo
timonla Oct 22, 2021
20082a6
Add isNull utility function
timonla Oct 22, 2021
b6c32f4
Rename faceitExtractor
timonla Oct 22, 2021
eb71032
Rename arrayAvg
timonla Oct 22, 2021
e8330c7
Move helper method outside of render function
timonla Oct 22, 2021
5964275
Use type alias
timonla Oct 22, 2021
c5ed48e
Add placeholder for no avg elo
timonla Oct 23, 2021
a317a4f
Refactor from undefined to null
timonla Oct 23, 2021
83a538d
Move scripts into features directory
timonla Oct 23, 2021
104fb8f
Only call faceitInfo renderer if not undefined
timonla Oct 23, 2021
4c79c25
Don't explicitly assign undefined
timonla Oct 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

44 changes: 44 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:wc/recommended',
'plugin:lit/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 12,
project: './tsconfig.json',
sourceType: 'module',
},
plugins: [
'@typescript-eslint',
],
rules: {
indent: [
'error',
2,
{ SwitchCase: 1 },
],
'linebreak-style': [
'error',
'unix',
],
quotes: [
'error',
'single',
],
semi: [
'error',
'always',
],
'comma-dangle': [
'error',
'always-multiline',
],
}
};
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI

on:
pull_request:
branches:
- '**'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm ci
- run: npm run lint
type-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm ci
- run: npm run type-check
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm ci
- run: npm run build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
node_modules/
dist/content/
dist/background.js
dist/LICENSE-DETAILS.md
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"runem.lit-plugin",
"formulahendry.auto-rename-tag"
]
}
38 changes: 38 additions & 0 deletions .vscode/typescript.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"WebComponent based on LitElement": {
"prefix": [
"webcomponent"
],
"body": [
"import '@webcomponents/webcomponentsjs';",
"import { LitElement, css, html } from 'lit';",
"import { customElement, property } from 'lit/decorators';",
"",
"const ${TM_FILENAME_BASE/([A-Z])(.*)/${1:/downcase}${2}/} = 'flashkill${TM_FILENAME_BASE/([A-Z])([a-z])/-${1:/downcase}${2}/g}';",
"",
"@customElement(${TM_FILENAME_BASE/([A-Z])(.*)/${1:/downcase}${2}/})",
"class ${TM_FILENAME_BASE} extends LitElement {",
"\t@property() $1",
"",
"\tstatic styles = css`",
"\t\t:host {",
"\t\t}",
"\t`;",
"",
"\trender() {",
"\t\treturn html`",
"\t\t\t$2",
"\t\t`;",
"\t}",
"}",
"",
"declare global {",
"\tinterface HTMLElementTagNameMap {",
"\t\t[${TM_FILENAME_BASE/([A-Z])(.*)/${1:/downcase}${2}/}]: ${TM_FILENAME_BASE},",
"\t}",
"};",
"",
],
"description": "WebComponent based on LitElement"
},
}
9 changes: 9 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = (api) => {
api.cache(true);
return {
presets: [
'@babel/preset-typescript',
'babel-preset-expo',
],
};
};
7 changes: 0 additions & 7 deletions dist/LICENSE-DETAILS.txt

This file was deleted.

4 changes: 2 additions & 2 deletions dist/licenseDetailsLoader.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const url = chrome.runtime.getURL("LICENSE-DETAILS.txt");
document.getElementById("license-link").href = url;
const url = chrome.runtime.getURL('LICENSE-DETAILS.md');
document.getElementById('license-link').href = url;
14 changes: 2 additions & 12 deletions dist/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
"version": "1.3.16",
"background": {
"scripts": [
"thirdParty/uint64.js",
"thirdParty/jquery-3.4.0.min.js",
"background.js"
]
},
Expand All @@ -16,23 +14,15 @@
"https://liga.99damage.de/*"
],
"js": [
"content/content.js"
"content/index.js"
]
},
{
"matches": [
"https://liga.99damage.de/leagues/teams/*-*"
],
"js": [
"thirdParty/jquery-3.4.0.min.js",
"thirdParty/jquery.dataTables.js",
"thirdParty/tooltipster.bundle.min.js",
"thirdParty/jquery.multiselect.js",
"content/team-page/members/index.js"
],
"css": [
"thirdParty/jquery.multiselect.css",
"thirdParty/tooltipster.bundle.min.css"
"content/team-page/index.js"
]
}
],
Expand Down
79 changes: 38 additions & 41 deletions dist/popup.html
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
<html>
<head>
<meta charset="utf-8" />
<title>flashkill</title>
<link rel="stylesheet" type="text/css" href="popup.css">
</head>
<body style="width: 450px; height: 580px; background-color: #222; color: white">
<img src="https://i.ibb.co/7vC3dsf/flashkill-logo-white.png" style="margin-left:auto; margin-right:auto; display:block; height:50"/>
<h3>Einstellungen</h3>
<table>
<tr>
<td>
Map Übersicht automatisch laden
</td>
<td>
<label class="switch">
<input id="maps-table-auto-load" type="checkbox">
<span class="slider round"></span>
<script src="script/popup.js"></script>
</label>
</td>
</tr>
</table>
<div style="margin-top: 10px">
<button id="clear-cache-button">Cache leeren<script src="./popup.js"></script></button>

<head>
<meta charset="utf-8" />
<title>flashkill</title>
<link rel="stylesheet" type="text/css" href="popup.css">
</head>

<body style="width: 450px; height: 580px; background-color: #222; color: white">
<img src="https://i.ibb.co/7vC3dsf/flashkill-logo-white.png"
style="margin-left:auto; margin-right:auto; display:block; height:50" />
<h3>Einstellungen</h3>
<div style="margin-top: 10px">
<button id="clear-cache-button">Cache leeren
<script src="./popup.js"></script>
</button>
<!-- <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=X489TLB8NSSPN&source=url" target="_blank">
<img src="https://i.ibb.co/vX4JLpg/clear-cache.png" width="100px"> -->
</div>
<h3>Feedback</h3>
<p>Wir arbeiten an weiteren Features und freuen uns auf euer Feedback, damit wir die Extension zum größtmöglichen Nutzen weiterentwickeln können.
Schreibt uns daher gerne eine E-Mail mit euren Verbesserungsvorschläge an <b>flashkillapp@gmail.com</b>
oder postet unter <a href="https://www.reddit.com/r/FlashkillApp" target="_blank" style="color:white">r/FlashkillApp</a>.</p>
<h3>Spenden</h3>
<p>Wir arbeiten in unserer Freizeit an diesem Projekt und sind dankbar für jede Spende auf unser PayPal Konto.</p>
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=X489TLB8NSSPN&source=url" target="_blank">
<img src="https://i.ibb.co/xXCmwJq/paypal-button-orange.png" width="150px">
</a>
<h3>About</h3>
<p>Version <script src="versionloader.js"></script></p>
<a id="license-link" target="_blank" style="color:white">Lizensinformationen zu verwendeter Open Source Software</a>
<script src="licenseDetailsLoader.js"></script>
<h3>Disclaimer</h3>
<p>Diese Extension steht in keiner direkten Verbindung zu 99Damage oder der Freaks 4U Gaming GmbH.</p>
</div>
<h3>Feedback</h3>
<p>Wir arbeiten an weiteren Features und freuen uns auf euer Feedback, damit wir die Extension zum größtmöglichen
Nutzen weiterentwickeln können.
Schreibt uns daher gerne eine E-Mail mit euren Verbesserungsvorschläge an <b>flashkillapp@gmail.com</b>
oder postet unter <a href="https://www.reddit.com/r/FlashkillApp" target="_blank"
style="color:white">r/FlashkillApp</a>.</p>
<h3>Spenden</h3>
<p>Wir arbeiten in unserer Freizeit an diesem Projekt und sind dankbar für jede Spende auf unser PayPal Konto.</p>
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=X489TLB8NSSPN&source=url"
target="_blank">
<img src="https://i.ibb.co/xXCmwJq/paypal-button-orange.png" width="150px">
</a>
<h3>About</h3>
<p>Version
<script src="versionloader.js"></script>
</p>
<a id="license-link" target="_blank" style="color:white">Lizensinformationen zu verwendeter Open Source Software</a>
<script src="licenseDetailsLoader.js"></script>
<h3>Disclaimer</h3>
<p>Diese Extension steht in keiner direkten Verbindung zu 99Damage oder der Freaks 4U Gaming GmbH.</p>
</body>
</html>

</html>
28 changes: 3 additions & 25 deletions dist/popup.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@

document.getElementById("clear-cache-button").onclick = clearCache;

function clearCache() {
chrome.storage.local.clear(() => alert("Cache wurde geleert."));
}

const mapsTableAutoLoadCheckbox = document.getElementById("maps-table-auto-load");

mapsTableAutoLoadCheckbox.onclick = changeMapsTableAutoLoad;

chrome.storage.sync.get(['mapsTableAutoLoad'], function(result) {
mapsTableAutoLoadCheckbox.checked = result.mapsTableAutoLoad;
});

function changeMapsTableAutoLoad() {
if (mapsTableAutoLoadCheckbox.checked) {
alert("Mit dieser Auswahl läufst du Gefahr einen IP-Ban von 99Damage zu erhalten, wenn du zu viele neue Teamseiten in kurze Zeit lädst. Die Änderung tritt ab dem nächsten Öffnen einer Teamseite in Kraft.");
chrome.storage.sync.set({ mapsTableAutoLoad: true }, () => {} );
}
else {
alert("Die Map Übersicht wird jetzt nicht mehr automatisch geladen. Nutze den entsprechenden Button, der anstelle der Maps Übersicht erscheint, zum analysieren der Maps eines Teams. Die Änderung tritt ab dem nächsten Öffnen einer Teamseite in Kraft.");
chrome.storage.sync.set({ mapsTableAutoLoad: false }, () => {} );
}
}
const clearCache = () => chrome.storage.local.clear(() => alert('Cache wurde geleert.'));

document.getElementById('clear-cache-button').onclick = clearCache;
2 changes: 0 additions & 2 deletions dist/thirdParty/jquery-3.4.0.min.js

This file was deleted.

Loading