feat: add the Nexus Archive project

This commit is contained in:
Krzysztof Sikorski 2024-05-05 11:57:54 +02:00
parent 01d274b404
commit 641baae559
Signed by: krzysztof-sikorski
GPG key ID: 4EB564BD08FE8476
144 changed files with 22325 additions and 0 deletions

View file

@ -0,0 +1,10 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 80
tab_width = 2

View file

@ -0,0 +1,45 @@
{
"env": {
"browser": true,
"webextensions": true,
"es2021": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "script"
},
"root": true,
"parser": "@babel/eslint-parser",
"rules": {
"curly": ["error", "all"],
"eqeqeq": ["error", "always"],
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"never",
{
"beforeStatementContinuationChars": "never"
}
],
"strict": [
"error",
"global"
],
"yoda": [
"error",
"always"
]
}
}

View file

@ -0,0 +1,9 @@
* text=auto
*.css text eol=lf
*.editorconfig text eol=lf
*.html text eol=lf
*.js text eol=lf
*.json text eol=lf
*.md text eol=lf
*.txt text eol=lf
*.png binary

View file

@ -0,0 +1,3 @@
/node_modules
/web-ext-artifacts
/.web-extension-id

View file

@ -0,0 +1,13 @@
# Version 1.1.1
- Fix version definition in manifest file
# Version 1.1.0
- Removed unnecessary entry for "unlimited storage" from required permissions
- Removed unnecessary properties from submitted data
- Removed some forgotten debugging code
# Version 1.0.0
- Created basic extension to automatically submit network traffic to the website

View file

@ -0,0 +1,287 @@
EUROPEAN UNION PUBLIC LICENCE v. 1.2
EUPL © the European Union 2007, 2016
This European Union Public Licence (the EUPL) applies to the Work (as defined
below) which is provided under the terms of this Licence. Any use of the Work,
other than as authorised under this Licence is prohibited (to the extent such
use is covered by a right of the copyright holder of the Work).
The Work is provided under the terms of this Licence when the Licensor (as
defined below) has placed the following notice immediately following the
copyright notice for the Work:
Licensed under the EUPL
or has expressed by any other means his willingness to license under the EUPL.
1. Definitions
In this Licence, the following terms have the following meaning:
- The Licence: this Licence.
- The Original Work: the work or software distributed or communicated by the
Licensor under this Licence, available as Source Code and also as Executable
Code as the case may be.
- Derivative Works: the works or software that could be created by the
Licensee, based upon the Original Work or modifications thereof. This Licence
does not define the extent of modification or dependence on the Original Work
required in order to classify a work as a Derivative Work; this extent is
determined by copyright law applicable in the country mentioned in Article 15.
- The Work: the Original Work or its Derivative Works.
- The Source Code: the human-readable form of the Work which is the most
convenient for people to study and modify.
- The Executable Code: any code which has generally been compiled and which is
meant to be interpreted by a computer as a program.
- The Licensor: the natural or legal person that distributes or communicates
the Work under the Licence.
- Contributor(s): any natural or legal person who modifies the Work under the
Licence, or otherwise contributes to the creation of a Derivative Work.
- The Licensee or You: any natural or legal person who makes any usage of
the Work under the terms of the Licence.
- Distribution or Communication: any act of selling, giving, lending,
renting, distributing, communicating, transmitting, or otherwise making
available, online or offline, copies of the Work or providing access to its
essential functionalities at the disposal of any other natural or legal
person.
2. Scope of the rights granted by the Licence
The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
sublicensable licence to do the following, for the duration of copyright vested
in the Original Work:
- use the Work in any circumstance and for all usage,
- reproduce the Work,
- modify the Work, and make Derivative Works based upon the Work,
- communicate to the public, including the right to make available or display
the Work or copies thereof to the public and perform publicly, as the case may
be, the Work,
- distribute the Work or copies thereof,
- lend and rent the Work or copies thereof,
- sublicense rights in the Work or copies thereof.
Those rights can be exercised on any media, supports and formats, whether now
known or later invented, as far as the applicable law permits so.
In the countries where moral rights apply, the Licensor waives his right to
exercise his moral right to the extent allowed by law in order to make effective
the licence of the economic rights here above listed.
The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to
any patents held by the Licensor, to the extent necessary to make use of the
rights granted on the Work under this Licence.
3. Communication of the Source Code
The Licensor may provide the Work either in its Source Code form, or as
Executable Code. If the Work is provided as Executable Code, the Licensor
provides in addition a machine-readable copy of the Source Code of the Work
along with each copy of the Work that the Licensor distributes or indicates, in
a notice following the copyright notice attached to the Work, a repository where
the Source Code is easily and freely accessible for as long as the Licensor
continues to distribute or communicate the Work.
4. Limitations on copyright
Nothing in this Licence is intended to deprive the Licensee of the benefits from
any exception or limitation to the exclusive rights of the rights owners in the
Work, of the exhaustion of those rights or of other applicable limitations
thereto.
5. Obligations of the Licensee
The grant of the rights mentioned above is subject to some restrictions and
obligations imposed on the Licensee. Those obligations are the following:
Attribution right: The Licensee shall keep intact all copyright, patent or
trademarks notices and all notices that refer to the Licence and to the
disclaimer of warranties. The Licensee must include a copy of such notices and a
copy of the Licence with every copy of the Work he/she distributes or
communicates. The Licensee must cause any Derivative Work to carry prominent
notices stating that the Work has been modified and the date of modification.
Copyleft clause: If the Licensee distributes or communicates copies of the
Original Works or Derivative Works, this Distribution or Communication will be
done under the terms of this Licence or of a later version of this Licence
unless the Original Work is expressly distributed only under this version of the
Licence — for example by communicating EUPL v. 1.2 only. The Licensee
(becoming Licensor) cannot offer or impose any additional terms or conditions on
the Work or Derivative Work that alter or restrict the terms of the Licence.
Compatibility clause: If the Licensee Distributes or Communicates Derivative
Works or copies thereof based upon both the Work and another work licensed under
a Compatible Licence, this Distribution or Communication can be done under the
terms of this Compatible Licence. For the sake of this clause, Compatible
Licence refers to the licences listed in the appendix attached to this Licence.
Should the Licensee's obligations under the Compatible Licence conflict with
his/her obligations under this Licence, the obligations of the Compatible
Licence shall prevail.
Provision of Source Code: When distributing or communicating copies of the Work,
the Licensee will provide a machine-readable copy of the Source Code or indicate
a repository where this Source will be easily and freely available for as long
as the Licensee continues to distribute or communicate the Work.
Legal Protection: This Licence does not grant permission to use the trade names,
trademarks, service marks, or names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the copyright notice.
6. Chain of Authorship
The original Licensor warrants that the copyright in the Original Work granted
hereunder is owned by him/her or licensed to him/her and that he/she has the
power and authority to grant the Licence.
Each Contributor warrants that the copyright in the modifications he/she brings
to the Work are owned by him/her or licensed to him/her and that he/she has the
power and authority to grant the Licence.
Each time You accept the Licence, the original Licensor and subsequent
Contributors grant You a licence to their contributions to the Work, under the
terms of this Licence.
7. Disclaimer of Warranty
The Work is a work in progress, which is continuously improved by numerous
Contributors. It is not a finished work and may therefore contain defects or
bugs inherent to this type of development.
For the above reason, the Work is provided under the Licence on an as is basis
and without warranties of any kind concerning the Work, including without
limitation merchantability, fitness for a particular purpose, absence of defects
or errors, accuracy, non-infringement of intellectual property rights other than
copyright as stated in Article 6 of this Licence.
This disclaimer of warranty is an essential part of the Licence and a condition
for the grant of any rights to the Work.
8. Disclaimer of Liability
Except in the cases of wilful misconduct or damages directly caused to natural
persons, the Licensor will in no event be liable for any direct or indirect,
material or moral, damages of any kind, arising out of the Licence or of the use
of the Work, including without limitation, damages for loss of goodwill, work
stoppage, computer failure or malfunction, loss of data or any commercial
damage, even if the Licensor has been advised of the possibility of such damage.
However, the Licensor will be liable under statutory product liability laws as
far such laws apply to the Work.
9. Additional agreements
While distributing the Work, You may choose to conclude an additional agreement,
defining obligations or services consistent with this Licence. However, if
accepting obligations, You may act only on your own behalf and on your sole
responsibility, not on behalf of the original Licensor or any other Contributor,
and only if You agree to indemnify, defend, and hold each Contributor harmless
for any liability incurred by, or claims asserted against such Contributor by
the fact You have accepted any warranty or additional liability.
10. Acceptance of the Licence
The provisions of this Licence can be accepted by clicking on an icon I agree
placed under the bottom of a window displaying the text of this Licence or by
affirming consent in any other similar way, in accordance with the rules of
applicable law. Clicking on that icon indicates your clear and irrevocable
acceptance of this Licence and all of its terms and conditions.
Similarly, you irrevocably accept this Licence and all of its terms and
conditions by exercising any rights granted to You by Article 2 of this Licence,
such as the use of the Work, the creation by You of a Derivative Work or the
Distribution or Communication by You of the Work or copies thereof.
11. Information to the public
In case of any Distribution or Communication of the Work by means of electronic
communication by You (for example, by offering to download the Work from a
remote location) the distribution channel or media (for example, a website) must
at least provide to the public the information requested by the applicable law
regarding the Licensor, the Licence and the way it may be accessible, concluded,
stored and reproduced by the Licensee.
12. Termination of the Licence
The Licence and the rights granted hereunder will terminate automatically upon
any breach by the Licensee of the terms of the Licence.
Such a termination will not terminate the licences of any person who has
received the Work from the Licensee under the Licence, provided such persons
remain in full compliance with the Licence.
13. Miscellaneous
Without prejudice of Article 9 above, the Licence represents the complete
agreement between the Parties as to the Work.
If any provision of the Licence is invalid or unenforceable under applicable
law, this will not affect the validity or enforceability of the Licence as a
whole. Such provision will be construed or reformed so as necessary to make it
valid and enforceable.
The European Commission may publish other linguistic versions or new versions of
this Licence or updated versions of the Appendix, so far this is required and
reasonable, without reducing the scope of the rights granted by the Licence. New
versions of the Licence will be published with a unique version number.
All linguistic versions of this Licence, approved by the European Commission,
have identical value. Parties can take advantage of the linguistic version of
their choice.
14. Jurisdiction
Without prejudice to specific agreement between parties,
- any litigation resulting from the interpretation of this License, arising
between the European Union institutions, bodies, offices or agencies, as a
Licensor, and any Licensee, will be subject to the jurisdiction of the Court
of Justice of the European Union, as laid down in article 272 of the Treaty on
the Functioning of the European Union,
- any litigation arising between other parties and resulting from the
interpretation of this License, will be subject to the exclusive jurisdiction
of the competent court where the Licensor resides or conducts its primary
business.
15. Applicable Law
Without prejudice to specific agreement between parties,
- this Licence shall be governed by the law of the European Union Member State
where the Licensor has his seat, resides or has his registered office,
- this licence shall be governed by Belgian law if the Licensor has no seat,
residence or registered office inside a European Union Member State.
Appendix
Compatible Licences according to Article 5 EUPL are:
- GNU General Public License (GPL) v. 2, v. 3
- GNU Affero General Public License (AGPL) v. 3
- Open Software License (OSL) v. 2.1, v. 3.0
- Eclipse Public License (EPL) v. 1.0
- CeCILL v. 2.0, v. 2.1
- Mozilla Public Licence (MPL) v. 2
- GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
- Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
works other than software
- European Union Public Licence (EUPL) v. 1.1, v. 1.2
- Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong
Reciprocity (LiLiQ-R+).
The European Commission may update this Appendix to later versions of the above
licences without producing a new version of the EUPL, as long as they provide
the rights granted in Article 2 of this Licence and protect the covered Source
Code from exclusive appropriation.
All other changes or additions to this Appendix require the production of a new
EUPL version.

View file

@ -0,0 +1,21 @@
# Nexus Archive browser extension
A simple browser extension to submit network traffic to the <q>Nexus Archive</q>
website.
## Licence
This project is licensed under [European Union Public Licence (EUPL)][EUPL].
For convenience an English text of the licence is included
in [LICENSE.txt](LICENSE.txt) file.
## Changelog
You can read changelog in a [separate file][CHANGELOG].
[EUPL]:
https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
[CHANGELOG]:
CHANGELOG.md

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

View file

@ -0,0 +1,38 @@
{
"author": "Krzysztof Andrzej Sikorski",
"background": {
"persistent": true,
"scripts": [
"src/preferences.js",
"src/nexusData.js",
"src/nexusDataQueue.js",
"src/nexusDataSender.js",
"src/webRequestMonitor.js",
"src/background.js"
]
},
"browser_specific_settings": {
"gecko": {
"id": "nexus-archive-tracker@zerozero.pl"
}
},
"description": "A browser extension to automatically submit Nexus Clash network traffic to the \"Nexus Archive\" website.",
"homepage_url": "https://discord.gg/zBVwzD3f8v",
"icons": {
"64": "icons/icon.png"
},
"manifest_version": 2,
"name": "Nexus Archive Tracker",
"options_ui": {
"browser_style": true,
"page": "options/index.html"
},
"permissions": [
"storage",
"webRequest",
"webRequestBlocking",
"*://*.nexusclash.com/*"
],
"short_name": "NA Tracker",
"version": "1.1.1"
}

View file

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en-GB">
<head>
<meta charset="UTF-8">
<title>Options - Nexus Archive Tracker</title>
<link href="style.css" rel="stylesheet" />
</head>
<body>
<form id="optionsForm" method="post">
<fieldset>
<legend>Tracker options</legend>
<p>
<label>
User access token:
<input name="userAccessToken" required size="64" type="text" pattern="[0-9A-Fa-f]+">
</label>
</p>
<p>
<label>
Submit form's URL:
<input name="trackerSubmitUrl" required size="64" type="url">
</label>
</p>
</fieldset>
<p>
<button type="submit">Save</button>
</p>
</form>
<script src="../src/preferences.js"></script>
<script src="../src/options.js"></script>
</body>
</html>

View file

@ -0,0 +1,3 @@
body {
padding: 0.5em 2ex;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,16 @@
{
"babel": {},
"devDependencies": {
"@babel/core": "^7.21.3",
"@babel/eslint-parser": "^7.21.3",
"eslint": "^8.36.0",
"request": "^2.88.2",
"web-ext": "^7.5.0"
},
"webExt": {
"ignoreFiles": [
"package.json",
"package-lock.json"
]
}
}

View file

@ -0,0 +1,13 @@
/* global NexusDataQueue, NexusDataSender, Preferences, WebRequestMonitor */
'use strict'
const preferences = new Preferences()
preferences.load()
preferences.listenForStorageChanges()
const nexusDataQueue = new NexusDataQueue()
const nexusDataSender = new NexusDataSender(preferences)
const webRequestMonitor = new WebRequestMonitor(nexusDataQueue, nexusDataSender)
webRequestMonitor.addListeners()

View file

@ -0,0 +1,81 @@
/* exported NexusData */
'use strict'
class NexusData {
constructor() {
this._requestId = null
this._requestStartedAt = null
this._responseCompletedAt = null
this._method = null
this._url = null
this._formData = null
this._responseBodyParts = []
}
get requestId() {
return this._requestId
}
set requestId(value) {
this._requestId = value
}
get requestStartedAt() {
return this._requestStartedAt
}
set requestStartedAt(value) {
if (!(value instanceof Date)) {
value = new Date(value)
}
this._requestStartedAt = value
}
get responseCompletedAt() {
return this._responseCompletedAt
}
set responseCompletedAt(value) {
if (!(value instanceof Date)) {
value = new Date(value)
}
this._responseCompletedAt = value
}
get method() {
return this._method
}
set method(value) {
this._method = value
}
get url() {
return this._url
}
set url(value) {
this._url = value
}
get formData() {
return this._formData
}
set formData(value) {
this._formData = value
}
get responseBody() {
return this._responseBodyParts.join('')
}
set responseBody(value) {
this._responseBodyParts = []
this.appendResponseBodyPart(value)
}
appendResponseBodyPart(value) {
this._responseBodyParts.push(value)
}
}

View file

@ -0,0 +1,33 @@
/* exported NexusDataQueue */
/* global NexusData */
'use strict'
class NexusDataQueue {
constructor() {
this._data = new Map()
}
push(nexusData) {
if (!(nexusData instanceof NexusData)) {
window.console.error('[NexusDataQueue] push: argument is not an instance of NexusData!')
}
this._data.set(nexusData.requestId, nexusData)
}
get(requestId) {
if (this._data.has(requestId)) {
return this._data.get(requestId)
}
return null
}
has(requestId) {
return this._data.has(requestId)
}
delete(requestId) {
if (this._data.has(requestId)) {
this._data.delete(requestId)
}
}
}

View file

@ -0,0 +1,52 @@
/* exported NexusDataSender */
/* global NexusData, Preferences */
'use strict'
class NexusDataSender {
constructor(preferences) {
if (!(preferences instanceof Preferences)) {
window.console.error('[NexusDataSender] constructor: argument is not an instance of Preferences!')
}
this._preferences = preferences
}
_formatDate(value) {
return value instanceof Date ? value.toISOString() : null
}
send(nexusData) {
if (!(nexusData instanceof NexusData)) {
window.console.error('[NexusDataSender] send: argument is not an instance of NexusData!')
}
if (false === this._preferences.isConfigured()) {
window.console.error('[NexusDataSender] send: preferences are not configured!')
return
}
const jsonData = {
requestStartedAt: this._formatDate(nexusData.requestStartedAt),
responseCompletedAt: this._formatDate(nexusData.responseCompletedAt),
method: nexusData.method,
url: nexusData.url,
formData: nexusData.formData,
responseBody: nexusData.responseBody,
}
const formData = new FormData()
formData.append('userAccessToken', this._preferences.userAccessToken)
formData.append('jsonData', JSON.stringify(jsonData, null, 2))
const fetchOptions = {
method: 'POST',
body: formData,
mode: 'no-cors',
}
window.fetch(this._preferences.trackerSubmitUrl, fetchOptions).catch(
error => {
window.console.error(`[NexusDataSender] Failed to send data: ${error}`)
}
)
}
}

View file

@ -0,0 +1,29 @@
/* global Preferences */
'use strict'
const preferences = new Preferences()
const getOptionsForm = () => document.getElementById('optionsForm')
const saveForm = event => {
event.preventDefault()
const optionsForm = getOptionsForm()
preferences.userAccessToken = optionsForm.elements['userAccessToken'].value
preferences.trackerSubmitUrl = optionsForm.elements['trackerSubmitUrl'].value
preferences.save()
}
const initForm = () => {
const optionsForm = getOptionsForm()
optionsForm.addEventListener('submit', saveForm)
preferences.load().then(
() => {
optionsForm.elements['userAccessToken'].value = preferences.userAccessToken
optionsForm.elements['trackerSubmitUrl'].value = preferences.trackerSubmitUrl
}
)
}
document.addEventListener('DOMContentLoaded', initForm)

View file

@ -0,0 +1,93 @@
/* exported Preferences */
'use strict'
class Preferences {
constructor() {
this._userAccessToken = null
this._trackerSubmitUrl = null
}
get userAccessToken() {
return this._userAccessToken
}
set userAccessToken(value) {
this._userAccessToken = value
}
get trackerSubmitUrl() {
return this._trackerSubmitUrl
}
set trackerSubmitUrl(value) {
this._trackerSubmitUrl = value
}
get _storage() {
return browser.storage.sync
}
hasUserAccessToken() {
return null !== this._userAccessToken && 0 < this._userAccessToken.length
}
hasTrackerSubmitUrl() {
return null !== this._trackerSubmitUrl && 0 < this._trackerSubmitUrl.length
}
isConfigured() {
return this.hasUserAccessToken() && this.hasTrackerSubmitUrl()
}
load() {
const storageGetter = this._storage.get(null)
storageGetter.then(
results => {
if (Object.prototype.hasOwnProperty.call(results, 'userAccessToken')) {
this.userAccessToken = results.userAccessToken
}
if (Object.prototype.hasOwnProperty.call(results, 'trackerSubmitUrl')) {
this.trackerSubmitUrl = results.trackerSubmitUrl
}
},
error => {
const message = `Error loading preferences: ${error}`
window.console.error(message)
window.alert(message)
}
)
return storageGetter
}
save() {
const storageSetter = this._storage.set({
userAccessToken: this.userAccessToken,
trackerSubmitUrl: this.trackerSubmitUrl
})
storageSetter.catch(
error => {
const message = `Error saving preferences: ${error}`
window.console.error(message)
window.alert(message)
}
)
return storageSetter
}
listenForStorageChanges() {
browser.storage.onChanged.addListener((changes, areaName) => {
if ('sync' === areaName) {
if (Object.prototype.hasOwnProperty.call(changes, 'userAccessToken')) {
this.userAccessToken = changes.userAccessToken.newValue
}
if (Object.prototype.hasOwnProperty.call(changes, 'trackerSubmitUrl')) {
this.trackerSubmitUrl = changes.trackerSubmitUrl.newValue
}
}
})
}
}

View file

@ -0,0 +1,86 @@
/* exported WebRequestMonitor */
/* global NexusData, NexusDataQueue, NexusDataSender */
'use strict'
class WebRequestMonitor {
constructor(nexusDataQueue, nexusDataSender) {
if (!(nexusDataQueue instanceof NexusDataQueue)) {
window.console.error('[NexusDataSender] constructor: argument is not an instance of NexusDataQueue!')
}
if (!(nexusDataSender instanceof NexusDataSender)) {
window.console.error('[NexusDataSender] constructor: argument is not an instance of NexusDataSender!')
}
this._nexusDataQueue = nexusDataQueue
this._nexusDataSender = nexusDataSender
}
_attachResponseDataFilter(nexusData) {
const decoder = new TextDecoder('utf-8')
const encoder = new TextEncoder()
const responseDataFilter = browser.webRequest.filterResponseData(nexusData.requestId)
responseDataFilter.ondata = event => {
const bodyPart = decoder.decode(event.data, {stream: true})
responseDataFilter.write(encoder.encode(bodyPart))
nexusData.appendResponseBodyPart(bodyPart)
}
responseDataFilter.onstop = event => {
const bodyPart = decoder.decode(event.data, {stream: false})
responseDataFilter.write(encoder.encode(bodyPart))
responseDataFilter.close()
nexusData.appendResponseBodyPart(bodyPart)
}
}
_onBeforeRequest(details) {
const nexusData = new NexusData()
nexusData.requestId = details.requestId
nexusData.requestStartedAt = details.timeStamp
nexusData.method = details.method
nexusData.url = details.url
if (
null !== details.requestBody &&
Object.prototype.hasOwnProperty.call(details.requestBody, 'formData')
) {
nexusData.formData = details.requestBody.formData
}
this._nexusDataQueue.push(nexusData)
this._attachResponseDataFilter(nexusData)
}
_onCompleted(details) {
const requestId = details.requestId
if (false !== this._nexusDataQueue.has(requestId)) {
const nexusData = this._nexusDataQueue.get(requestId)
nexusData.responseCompletedAt = details.timeStamp
this._nexusDataQueue.delete(requestId)
this._nexusDataSender.send(nexusData)
}
}
_onErrorOccurred(details) {
this._nexusDataQueue.delete(details.requestId)
window.console.error('[WebRequestMonitor] Error has occurred: ' + details.error)
}
addListeners() {
const requestFilters = {
types: ['main_frame'],
urls: [
'*://*.nexusclash.com/*'
]
}
browser.webRequest.onBeforeRequest.addListener(
this._onBeforeRequest.bind(this),
requestFilters,
['blocking', 'requestBody']
)
browser.webRequest.onCompleted.addListener(
this._onCompleted.bind(this),
requestFilters
)
browser.webRequest.onErrorOccurred.addListener(
this._onErrorOccurred.bind(this),
requestFilters
)
}
}

View file

@ -0,0 +1,28 @@
root = true
[*]
charset = utf-8
end_of_line = LF
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
[*.md]
max_line_length = 80
[*.html]
indent_size = 4
[*.php]
# settings required by PSR-12 standard
end_of_line = LF
indent_style = space
indent_size = 4
max_line_length = 120
[*.twig]
indent_size = 4
[*.yaml]
indent_size = 4

View file

@ -0,0 +1,12 @@
# essential framework settings
APP_ENV=dev
APP_SECRET=
APP_WORKER_PARSER_BATCH_SIZE=1
APP_WORKER_PARSER_MAX_ITERATIONS=1
APP_WORKER_PARSER_MAX_DURATION="1 second"
# doctrine settings
DATABASE_URL="postgresql://symfony:ChangeMe@127.0.0.1:5432/app?serverVersion=13&charset=utf8"
# lock component settings
LOCK_DSN=semaphore

8
2021/nexus-archive/website/.gitignore vendored Normal file
View file

@ -0,0 +1,8 @@
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/node_modules/
/public/bundles/
/var/
/vendor/

View file

@ -0,0 +1,41 @@
# Version 1.0.0
- create interfaces and classes to represent leaderboard table as seen in game
- create Doctrine entities to persist these leaderboard tables in database
- implement general parser infrastructure to handle stored page views
- implement parser for Breath 4 final leaderboards
- implement a public page for browsing leaderboards
- create and apply basic UI theme/styling, based on Tailwind CSS
- some more internal code cleanups
# Version 0.5.0
- fix crash in token command on empty username input
- create basic admin panel
- convert all config files to PHP format
- general code cleanup and refactoring
- update installed dependencies to newer versions
- update Symfony recipes metadata, port changes to appropriate files
- start using Doctrine Migrations: create initial migration for existing tables
# Version 0.4.0
- remove unnecessary properties from NexusRawData
# Version 0.3.0
- remove NexusRequestLog entity and all related code (form, repository, etc)
# Version 0.2.0
- create new form to handle data format expected from browser extension
# Version 0.1.1
- fix parsing of JSON fields at cost of ignoring JSON syntax errors
# Version 0.1.0
- basic submit form to store request logs for further processing
- primitive authentication via access tokens
- simple console commands to create user accounts and access tokens

View file

@ -0,0 +1,287 @@
EUROPEAN UNION PUBLIC LICENCE v. 1.2
EUPL © the European Union 2007, 2016
This European Union Public Licence (the EUPL) applies to the Work (as defined
below) which is provided under the terms of this Licence. Any use of the Work,
other than as authorised under this Licence is prohibited (to the extent such
use is covered by a right of the copyright holder of the Work).
The Work is provided under the terms of this Licence when the Licensor (as
defined below) has placed the following notice immediately following the
copyright notice for the Work:
Licensed under the EUPL
or has expressed by any other means his willingness to license under the EUPL.
1. Definitions
In this Licence, the following terms have the following meaning:
- The Licence: this Licence.
- The Original Work: the work or software distributed or communicated by the
Licensor under this Licence, available as Source Code and also as Executable
Code as the case may be.
- Derivative Works: the works or software that could be created by the
Licensee, based upon the Original Work or modifications thereof. This Licence
does not define the extent of modification or dependence on the Original Work
required in order to classify a work as a Derivative Work; this extent is
determined by copyright law applicable in the country mentioned in Article 15.
- The Work: the Original Work or its Derivative Works.
- The Source Code: the human-readable form of the Work which is the most
convenient for people to study and modify.
- The Executable Code: any code which has generally been compiled and which is
meant to be interpreted by a computer as a program.
- The Licensor: the natural or legal person that distributes or communicates
the Work under the Licence.
- Contributor(s): any natural or legal person who modifies the Work under the
Licence, or otherwise contributes to the creation of a Derivative Work.
- The Licensee or You: any natural or legal person who makes any usage of
the Work under the terms of the Licence.
- Distribution or Communication: any act of selling, giving, lending,
renting, distributing, communicating, transmitting, or otherwise making
available, online or offline, copies of the Work or providing access to its
essential functionalities at the disposal of any other natural or legal
person.
2. Scope of the rights granted by the Licence
The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
sublicensable licence to do the following, for the duration of copyright vested
in the Original Work:
- use the Work in any circumstance and for all usage,
- reproduce the Work,
- modify the Work, and make Derivative Works based upon the Work,
- communicate to the public, including the right to make available or display
the Work or copies thereof to the public and perform publicly, as the case may
be, the Work,
- distribute the Work or copies thereof,
- lend and rent the Work or copies thereof,
- sublicense rights in the Work or copies thereof.
Those rights can be exercised on any media, supports and formats, whether now
known or later invented, as far as the applicable law permits so.
In the countries where moral rights apply, the Licensor waives his right to
exercise his moral right to the extent allowed by law in order to make effective
the licence of the economic rights here above listed.
The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to
any patents held by the Licensor, to the extent necessary to make use of the
rights granted on the Work under this Licence.
3. Communication of the Source Code
The Licensor may provide the Work either in its Source Code form, or as
Executable Code. If the Work is provided as Executable Code, the Licensor
provides in addition a machine-readable copy of the Source Code of the Work
along with each copy of the Work that the Licensor distributes or indicates, in
a notice following the copyright notice attached to the Work, a repository where
the Source Code is easily and freely accessible for as long as the Licensor
continues to distribute or communicate the Work.
4. Limitations on copyright
Nothing in this Licence is intended to deprive the Licensee of the benefits from
any exception or limitation to the exclusive rights of the rights owners in the
Work, of the exhaustion of those rights or of other applicable limitations
thereto.
5. Obligations of the Licensee
The grant of the rights mentioned above is subject to some restrictions and
obligations imposed on the Licensee. Those obligations are the following:
Attribution right: The Licensee shall keep intact all copyright, patent or
trademarks notices and all notices that refer to the Licence and to the
disclaimer of warranties. The Licensee must include a copy of such notices and a
copy of the Licence with every copy of the Work he/she distributes or
communicates. The Licensee must cause any Derivative Work to carry prominent
notices stating that the Work has been modified and the date of modification.
Copyleft clause: If the Licensee distributes or communicates copies of the
Original Works or Derivative Works, this Distribution or Communication will be
done under the terms of this Licence or of a later version of this Licence
unless the Original Work is expressly distributed only under this version of the
Licence — for example by communicating EUPL v. 1.2 only. The Licensee
(becoming Licensor) cannot offer or impose any additional terms or conditions on
the Work or Derivative Work that alter or restrict the terms of the Licence.
Compatibility clause: If the Licensee Distributes or Communicates Derivative
Works or copies thereof based upon both the Work and another work licensed under
a Compatible Licence, this Distribution or Communication can be done under the
terms of this Compatible Licence. For the sake of this clause, Compatible
Licence refers to the licences listed in the appendix attached to this Licence.
Should the Licensee's obligations under the Compatible Licence conflict with
his/her obligations under this Licence, the obligations of the Compatible
Licence shall prevail.
Provision of Source Code: When distributing or communicating copies of the Work,
the Licensee will provide a machine-readable copy of the Source Code or indicate
a repository where this Source will be easily and freely available for as long
as the Licensee continues to distribute or communicate the Work.
Legal Protection: This Licence does not grant permission to use the trade names,
trademarks, service marks, or names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the copyright notice.
6. Chain of Authorship
The original Licensor warrants that the copyright in the Original Work granted
hereunder is owned by him/her or licensed to him/her and that he/she has the
power and authority to grant the Licence.
Each Contributor warrants that the copyright in the modifications he/she brings
to the Work are owned by him/her or licensed to him/her and that he/she has the
power and authority to grant the Licence.
Each time You accept the Licence, the original Licensor and subsequent
Contributors grant You a licence to their contributions to the Work, under the
terms of this Licence.
7. Disclaimer of Warranty
The Work is a work in progress, which is continuously improved by numerous
Contributors. It is not a finished work and may therefore contain defects or
bugs inherent to this type of development.
For the above reason, the Work is provided under the Licence on an as is basis
and without warranties of any kind concerning the Work, including without
limitation merchantability, fitness for a particular purpose, absence of defects
or errors, accuracy, non-infringement of intellectual property rights other than
copyright as stated in Article 6 of this Licence.
This disclaimer of warranty is an essential part of the Licence and a condition
for the grant of any rights to the Work.
8. Disclaimer of Liability
Except in the cases of wilful misconduct or damages directly caused to natural
persons, the Licensor will in no event be liable for any direct or indirect,
material or moral, damages of any kind, arising out of the Licence or of the use
of the Work, including without limitation, damages for loss of goodwill, work
stoppage, computer failure or malfunction, loss of data or any commercial
damage, even if the Licensor has been advised of the possibility of such damage.
However, the Licensor will be liable under statutory product liability laws as
far such laws apply to the Work.
9. Additional agreements
While distributing the Work, You may choose to conclude an additional agreement,
defining obligations or services consistent with this Licence. However, if
accepting obligations, You may act only on your own behalf and on your sole
responsibility, not on behalf of the original Licensor or any other Contributor,
and only if You agree to indemnify, defend, and hold each Contributor harmless
for any liability incurred by, or claims asserted against such Contributor by
the fact You have accepted any warranty or additional liability.
10. Acceptance of the Licence
The provisions of this Licence can be accepted by clicking on an icon I agree
placed under the bottom of a window displaying the text of this Licence or by
affirming consent in any other similar way, in accordance with the rules of
applicable law. Clicking on that icon indicates your clear and irrevocable
acceptance of this Licence and all of its terms and conditions.
Similarly, you irrevocably accept this Licence and all of its terms and
conditions by exercising any rights granted to You by Article 2 of this Licence,
such as the use of the Work, the creation by You of a Derivative Work or the
Distribution or Communication by You of the Work or copies thereof.
11. Information to the public
In case of any Distribution or Communication of the Work by means of electronic
communication by You (for example, by offering to download the Work from a
remote location) the distribution channel or media (for example, a website) must
at least provide to the public the information requested by the applicable law
regarding the Licensor, the Licence and the way it may be accessible, concluded,
stored and reproduced by the Licensee.
12. Termination of the Licence
The Licence and the rights granted hereunder will terminate automatically upon
any breach by the Licensee of the terms of the Licence.
Such a termination will not terminate the licences of any person who has
received the Work from the Licensee under the Licence, provided such persons
remain in full compliance with the Licence.
13. Miscellaneous
Without prejudice of Article 9 above, the Licence represents the complete
agreement between the Parties as to the Work.
If any provision of the Licence is invalid or unenforceable under applicable
law, this will not affect the validity or enforceability of the Licence as a
whole. Such provision will be construed or reformed so as necessary to make it
valid and enforceable.
The European Commission may publish other linguistic versions or new versions of
this Licence or updated versions of the Appendix, so far this is required and
reasonable, without reducing the scope of the rights granted by the Licence. New
versions of the Licence will be published with a unique version number.
All linguistic versions of this Licence, approved by the European Commission,
have identical value. Parties can take advantage of the linguistic version of
their choice.
14. Jurisdiction
Without prejudice to specific agreement between parties,
- any litigation resulting from the interpretation of this License, arising
between the European Union institutions, bodies, offices or agencies, as a
Licensor, and any Licensee, will be subject to the jurisdiction of the Court
of Justice of the European Union, as laid down in article 272 of the Treaty on
the Functioning of the European Union,
- any litigation arising between other parties and resulting from the
interpretation of this License, will be subject to the exclusive jurisdiction
of the competent court where the Licensor resides or conducts its primary
business.
15. Applicable Law
Without prejudice to specific agreement between parties,
- this Licence shall be governed by the law of the European Union Member State
where the Licensor has his seat, resides or has his registered office,
- this licence shall be governed by Belgian law if the Licensor has no seat,
residence or registered office inside a European Union Member State.
Appendix
Compatible Licences according to Article 5 EUPL are:
- GNU General Public License (GPL) v. 2, v. 3
- GNU Affero General Public License (AGPL) v. 3
- Open Software License (OSL) v. 2.1, v. 3.0
- Eclipse Public License (EPL) v. 1.0
- CeCILL v. 2.0, v. 2.1
- Mozilla Public Licence (MPL) v. 2
- GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
- Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
works other than software
- European Union Public Licence (EUPL) v. 1.1, v. 1.2
- Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong
Reciprocity (LiLiQ-R+).
The European Commission may update this Appendix to later versions of the above
licences without producing a new version of the EUPL, as long as they provide
the rights granted in Article 2 of this Licence and protect the covered Source
Code from exclusive appropriation.
All other changes or additions to this Appendix require the production of a new
EUPL version.

View file

@ -0,0 +1,77 @@
# Nexus Archive
The <q>Nexus Archive</q> website, based on Symfony framework.
## Licence
This project is licensed under [European Union Public Licence (EUPL)][EUPL].
For convenience an English text of the licence is included
in [LICENSE.txt](./LICENSE.txt) file.
## Repositories
Source code is primarily hosted
on [my private Git server](https://git.zerozero.pl/nexus-archive), but for
convenience and redundancy it is also mirrored to a few popular code hosting
portals:
- [Gitlab mirror](https://gitlab.com/krzysztof-sikorski/nexus-archive)
- [GitHub mirror](https://github.com/krzysztof-sikorski/nexus-archive)
- [Launchpad mirror](https://git.launchpad.net/nexus-archive)
## Installation and deployment
This is a standard Symfony-based web application, requiring only a standard
software stack of:
- an http server (e.g. Nginx)
- PHP binaries and some standard extensions (
see [composer.json file](./composer.json) for details)
- [Composer][Composer] tool (for fetching and installing third-party PHP
libraries)
- a relational database server supporting SQL language (e.g. PostgreSQL)
You can find some generic advice in Symfony documentation,
in [installation][SymfonyInstallation]
and [deployment][SymfonyDeployment] chapters.
The application was only tested on PostgreSQL, but it should theoretically work
on any database engine that is supported by Doctrine library.
Check [Doctrine documentation][DoctrineVendors] for details.
On Linux Mint (and probably also Ubuntu or Debian) you can use following
commands to install required system packages:
```shell
sudo apt-get install php-cli php-fpm postgresql # basic packages
sudo apt-get install php-xml php-mbstring php-intl php-xml # required or recommended by Symfony
sudo apt-get install php-pgsql # required by application design
```
Remember to also configure periodic execution of following console commands
(e.g. via cron jobs or systemd timers):
- `bin/console app:worker:parser` for parsing submitted data
- `bin/console app:worker:prune-database` for pruning unwanted rows from db
## Development notes
- some classes are loaded from `var\cache` directory, so you have to
execute `bin/console cache:warmup` to have them available for IDE
autocompletion
[EUPL]:
https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
[Composer]:
https://getcomposer.org/
[SymfonyInstallation]:
https://symfony.com/doc/current/setup.html
[SymfonyDeployment]:
https://symfony.com/doc/current/deployment.html
[DoctrineVendors]:
https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/introduction.html

View file

@ -0,0 +1,45 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://nexus-archive.zerozero.pl/submit-json",
"type": "object",
"properties": {
"requestStartedAt": {
"type": "string",
"format": "date-time"
},
"responseCompletedAt": {
"type": "string",
"format": "date-time"
},
"method": {
"type": "string",
"enum": [
"GET",
"POST"
]
},
"url": {
"type": "string",
"format": "uri"
},
"formData": {
"type": [
"object",
"null"
],
"additionalProperties": true
},
"responseBody": {
"type": "string"
}
},
"required": [
"requestStartedAt",
"responseCompletedAt",
"method",
"url",
"formData",
"responseBody"
],
"additionalProperties": false
}

View file

@ -0,0 +1,65 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
a {
@apply tw-text-blue-900;
}
a[rel="external"]:after {
content: ' ↗';
}
button[type="submit"] {
@apply tw-px-4 tw-py-2 tw-font-bold tw-text-white tw-bg-black tw-rounded-lg;
}
body > * {
@apply tw-mx-8 tw-my-4;
}
header {
@apply tw-flex;
}
header a {
@apply tw-text-white;
}
header menu {
@apply tw-flex
tw-text-xl tw-font-bold tw-leading-loose
tw-text-white tw-bg-black
tw-border-solid tw-rounded-xl
tw-divide-x-4 tw-divide-dotted tw-divide-white
tw-shadow-lg;
}
header menu > li {
@apply tw-px-8 tw-py-2;
}
main h1 {
@apply tw-text-4xl tw-font-bold tw-leading-loose;
}
table {
@apply tw-my-4 tw-border-collapse;
}
table th, table td {
@apply tw-border-solid tw-border-2 tw-border-black tw-px-4 tw-py-2;
}
section.leaderboard-grid {
@apply tw-grid tw-gap-x-8 tw-gap-y-4
tw-grid-cols-1 md:tw-grid-cols-2 xl:tw-grid-cols-3;
}
section.leaderboard-grid caption {
@apply tw-text-lg tw-font-bold;
}
section.leaderboard-grid article.error {
@apply tw-my-4 tw-text-red-500 tw-text-lg tw-font-bold;
}

View file

@ -0,0 +1,18 @@
#!/usr/bin/env php
<?php
declare(strict_types=1);
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
if (!is_file(dirname(__DIR__) . '/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}
require_once dirname(__DIR__) . '/vendor/autoload_runtime.php';
return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool)$context['APP_DEBUG']);
return new Application($kernel);
};

View file

@ -0,0 +1,2 @@
#!/usr/bin/env sh
npx tailwindcss --input=assets/tailwindcss/input.css --output=public/css/combined.css --watch

View file

@ -0,0 +1,2 @@
#!/usr/bin/env sh
npx tailwindcss --input=assets/tailwindcss/input.css --output=public/css/combined.css --minify

View file

@ -0,0 +1,113 @@
{
"name": "krzysztof-sikorski/nexus-archive",
"description": "The \"Nexus Archive\" website, based on Symfony framework.",
"type": "project",
"keywords": [
"php",
"symfony",
"game",
"pbbg",
"nexus-clash"
],
"license": "EUPL-1.2",
"authors": [
{
"name": "Krzysztof Andrzej Sikorski",
"role": "Main Developer"
}
],
"require": {
"php": "^8.2",
"ext-ctype": "*",