Compare commits
10 Commits
4578c6af8d
...
e3a429bb32
Author | SHA1 | Date |
---|---|---|
Krzysztof Sikorski | e3a429bb32 | |
Krzysztof Sikorski | e109e94fbc | |
Krzysztof Sikorski | e753c63a01 | |
Krzysztof Sikorski | 83d45fdcc7 | |
Krzysztof Sikorski | c1e1ae0403 | |
Krzysztof Sikorski | 3f209bcf6a | |
Krzysztof Sikorski | cc6006f3a8 | |
Krzysztof Sikorski | 19e14c2ef8 | |
Krzysztof Sikorski | 64730cb8fb | |
Krzysztof Sikorski | 0369602844 |
|
@ -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
|
13
README.md
13
README.md
|
@ -1,12 +1,21 @@
|
|||
# Nexus Archive browser extension
|
||||
|
||||
A simple browser extension to submit network traffic to the <q>Nexus Archive</q> website.
|
||||
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.
|
||||
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
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
{
|
||||
"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"
|
||||
]
|
||||
},
|
||||
|
@ -22,8 +28,11 @@
|
|||
"page": "options/index.html"
|
||||
},
|
||||
"permissions": [
|
||||
"storage"
|
||||
"storage",
|
||||
"webRequest",
|
||||
"webRequestBlocking",
|
||||
"*://*.nexusclash.com/*"
|
||||
],
|
||||
"short_name": "NA Tracker",
|
||||
"version": "0.0.2"
|
||||
"version": "1.1.1"
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
"babel": {},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.16.0",
|
||||
"@babel/eslint-parser": "^7.16.0",
|
||||
"eslint": "^8.2.0",
|
||||
"web-ext": "^6.5.0"
|
||||
"@babel/core": "^7.17.2",
|
||||
"@babel/eslint-parser": "^7.17.0",
|
||||
"eslint": "^8.8.0",
|
||||
"web-ext": "^6.7.0"
|
||||
},
|
||||
"webExt": {
|
||||
"ignoreFiles": [
|
||||
|
|
|
@ -1 +1,13 @@
|
|||
// Put all the javascript code here, that you want to execute in background.
|
||||
/* 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()
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
|
||||
class NexusData {
|
||||
constructor() {
|
||||
this._sessionId = null
|
||||
this._requestId = null
|
||||
this._previousRequestId = null
|
||||
this._requestStartedAt = null
|
||||
this._responseCompletedAt = null
|
||||
this._method = null
|
||||
|
@ -14,14 +12,6 @@ class NexusData {
|
|||
this._responseBodyParts = []
|
||||
}
|
||||
|
||||
get sessionId() {
|
||||
return this._sessionId
|
||||
}
|
||||
|
||||
set sessionId(value) {
|
||||
this._sessionId = value
|
||||
}
|
||||
|
||||
get requestId() {
|
||||
return this._requestId
|
||||
}
|
||||
|
@ -30,14 +20,6 @@ class NexusData {
|
|||
this._requestId = value
|
||||
}
|
||||
|
||||
get previousRequestId() {
|
||||
return this._previousRequestId
|
||||
}
|
||||
|
||||
set previousRequestId(value) {
|
||||
this._previousRequestId = value
|
||||
}
|
||||
|
||||
get requestStartedAt() {
|
||||
return this._requestStartedAt
|
||||
}
|
||||
|
|
|
@ -5,15 +5,12 @@
|
|||
class NexusDataQueue {
|
||||
constructor() {
|
||||
this._data = new Map()
|
||||
this._currentRequestId = null
|
||||
}
|
||||
|
||||
push(nexusData) {
|
||||
if (!(nexusData instanceof NexusData)) {
|
||||
window.console.error('[NexusDataQueue] push: argument is not an instance of NexusData!')
|
||||
}
|
||||
nexusData.previousRequestId = this._currentRequestId
|
||||
this._currentRequestId = nexusData.requestId
|
||||
this._data.set(nexusData.requestId, nexusData)
|
||||
}
|
||||
|
||||
|
|
|
@ -25,9 +25,6 @@ class NexusDataSender {
|
|||
}
|
||||
|
||||
const jsonData = {
|
||||
sessionId: nexusData.sessionId,
|
||||
requestId: nexusData.requestId,
|
||||
previousRequestId: nexusData.previousRequestId,
|
||||
requestStartedAt: this._formatDate(nexusData.requestStartedAt),
|
||||
responseCompletedAt: this._formatDate(nexusData.responseCompletedAt),
|
||||
method: nexusData.method,
|
||||
|
|
|
@ -20,8 +20,6 @@ const initForm = () => {
|
|||
|
||||
preferences.load().then(
|
||||
() => {
|
||||
window.console.debug('[options] CALL preferences.load().then') // TODO tmp
|
||||
window.console.debug('[options] preferences:', preferences) // TODO tmp
|
||||
optionsForm.elements['userAccessToken'].value = preferences.userAccessToken
|
||||
optionsForm.elements['trackerSubmitUrl'].value = preferences.trackerSubmitUrl
|
||||
}
|
||||
|
|
|
@ -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
|
||||
)
|
||||
}
|
||||
}
|
Reference in New Issue