kernel-loophole commited on
Commit ·
c9fcff6
1
Parent(s): 05e8104
Create chrome extension
Browse filesRelease CD
Add extension tests
- .github/workflows/Extension_test.yml +48 -0
- .github/workflows/{release_ci.yml → release.yml} +39 -40
- .github/workflows/run_e2e_tests.yml +1 -0
- earth/Tests/BackgroundSpec.js +112 -0
- earth/Tests/background.js +31 -0
- earth/Tests/content.js +5 -0
- earth/Tests/manifest.json +45 -0
- earth/Tests/popup.css +15 -0
- earth/Tests/popup.html +27 -0
- earth/Tests/popup.js +17 -0
.github/workflows/Extension_test.yml
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Extension Test and Release
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches: [ "main" ]
|
| 6 |
+
pull_request:
|
| 7 |
+
branches: [ "main" ]
|
| 8 |
+
workflow_dispatch:
|
| 9 |
+
|
| 10 |
+
jobs:
|
| 11 |
+
test:
|
| 12 |
+
runs-on: ubuntu-latest
|
| 13 |
+
|
| 14 |
+
steps:
|
| 15 |
+
- name: Checkout code
|
| 16 |
+
uses: actions/checkout@v2
|
| 17 |
+
|
| 18 |
+
- name: Debug BackgroundSpec
|
| 19 |
+
run: cat /home/runner/work/puppet/puppet/earth/Tests/BackgroundSpec.js
|
| 20 |
+
|
| 21 |
+
- name: Setup Node.js
|
| 22 |
+
uses: actions/setup-node@v2
|
| 23 |
+
with:
|
| 24 |
+
node-version: 14 # Change to your preferred Node.js version
|
| 25 |
+
|
| 26 |
+
- name: Clear npm cache
|
| 27 |
+
run: npm cache clean --force
|
| 28 |
+
|
| 29 |
+
- name: Clear Yarn cache
|
| 30 |
+
run: yarn cache clean
|
| 31 |
+
|
| 32 |
+
- name: Install dependencies
|
| 33 |
+
run: npm install
|
| 34 |
+
|
| 35 |
+
- name: Run Jasmine tests
|
| 36 |
+
run: npm install --save-dev jasmine
|
| 37 |
+
|
| 38 |
+
- name: Configure Jasmine
|
| 39 |
+
run: npm install -g jasmine
|
| 40 |
+
|
| 41 |
+
- name: Install jasmine-ajax
|
| 42 |
+
run: npm install jasmine-ajax --save-dev
|
| 43 |
+
|
| 44 |
+
- name: Configure project
|
| 45 |
+
run: npx jasmine init
|
| 46 |
+
|
| 47 |
+
- name: Test project
|
| 48 |
+
run: npx jasmine /home/runner/work/puppet/puppet/earth/Tests/BackgroundSpec.js
|
.github/workflows/{release_ci.yml → release.yml}
RENAMED
|
@@ -1,24 +1,20 @@
|
|
| 1 |
-
name: Release
|
| 2 |
-
|
| 3 |
-
main_project_module: app
|
| 4 |
on:
|
| 5 |
push:
|
| 6 |
-
paths:
|
| 7 |
-
- "puppet/**"
|
| 8 |
tags:
|
| 9 |
- '*'
|
| 10 |
workflow_dispatch:
|
|
|
|
| 11 |
jobs:
|
| 12 |
build-android:
|
| 13 |
-
permissions: write-all
|
| 14 |
runs-on: ubuntu-latest
|
| 15 |
-
|
| 16 |
-
run:
|
| 17 |
-
working-directory: puppet
|
| 18 |
steps:
|
| 19 |
- uses: actions/checkout@v3
|
| 20 |
# Set Current Date As Env Variable
|
| 21 |
- name: Set current date as env variable
|
|
|
|
| 22 |
run: echo "date_today=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
| 23 |
|
| 24 |
# Set Repository Name As Env Variable
|
|
@@ -34,13 +30,11 @@ jobs:
|
|
| 34 |
|
| 35 |
- name: Grant execute permission for gradlew
|
| 36 |
run: chmod +x gradlew
|
| 37 |
-
|
| 38 |
-
# Run Tests Build
|
| 39 |
-
- name: Run gradle tests
|
| 40 |
-
run: ./gradlew test
|
| 41 |
|
| 42 |
- name: Build with Gradle
|
| 43 |
run: ./gradlew build
|
|
|
|
| 44 |
|
| 45 |
- name: Archive lint results
|
| 46 |
if: always()
|
|
@@ -48,61 +42,47 @@ jobs:
|
|
| 48 |
with:
|
| 49 |
name: lint-report
|
| 50 |
path: app/build/reports/lint-results-debug.html
|
| 51 |
-
|
| 52 |
-
# Create APK Debug
|
| 53 |
- name: Build apk debug project (APK) - ${{ env.main_project_module }} module
|
| 54 |
env:
|
| 55 |
UUID: ${{ secrets.UUID}}
|
| 56 |
SERVER_URL: ${{ secrets.SERVER_URL }}
|
| 57 |
run: ./gradlew assembleDebug
|
| 58 |
-
|
| 59 |
-
# Create APK Release
|
| 60 |
- name: Build apk release project (APK) - ${{ env.main_project_module }} module
|
| 61 |
env:
|
| 62 |
UUID: ${{ secrets.RELEASE_UUID}}
|
| 63 |
SERVER_URL: ${{ secrets.RELEASE_SERVER_URL }}
|
| 64 |
run: ./gradlew assemble
|
| 65 |
-
|
| 66 |
-
# Create Bundle AAB Release
|
| 67 |
-
# Noted for main module build [main_project_module]:bundleRelease
|
| 68 |
- name: Build app bundle release (AAB) - ${{ env.main_project_module }} module
|
| 69 |
-
run: ./gradlew
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
- name: Upload APK Debug - ${{ env.repository_name }}
|
| 74 |
uses: actions/upload-artifact@v2
|
| 75 |
with:
|
| 76 |
name: android-debug
|
| 77 |
path: puppet/${{ env.main_project_module }}/build/outputs/apk/debug/
|
| 78 |
-
|
| 79 |
-
# Noted For Output [main_project_module]/build/outputs/apk/release/
|
| 80 |
- name: Upload APK Release - ${{ env.repository_name }}
|
| 81 |
uses: actions/upload-artifact@v2
|
| 82 |
with:
|
| 83 |
name: android-release
|
| 84 |
path: puppet/${{ env.main_project_module }}/build/outputs/apk/release/
|
| 85 |
-
|
| 86 |
-
# Noted For Output [main_project_module]/build/outputs/bundle/release/
|
| 87 |
- name: Upload AAB (App Bundle) Release - ${{ env.repository_name }}
|
| 88 |
uses: actions/upload-artifact@v2
|
| 89 |
with:
|
| 90 |
name: android-bundle
|
| 91 |
path: puppet/${{ env.main_project_module }}/build/outputs/bundle/release/
|
| 92 |
-
|
| 93 |
-
release:
|
| 94 |
-
needs: [build-android]
|
| 95 |
-
permissions: write-all
|
| 96 |
-
runs-on: ubuntu-latest
|
| 97 |
-
steps:
|
| 98 |
- name: Download All Artifacts
|
| 99 |
uses: actions/download-artifact@v3
|
| 100 |
with:
|
| 101 |
path: ./
|
| 102 |
-
|
| 103 |
-
- name: Display structure of downloaded files
|
| 104 |
-
run: ls -R
|
| 105 |
-
|
| 106 |
- name: Create Release
|
| 107 |
id: create_release
|
| 108 |
uses: actions/create-release@v1
|
|
@@ -113,13 +93,32 @@ jobs:
|
|
| 113 |
release_name: Release ${{ github.ref }}
|
| 114 |
draft: false
|
| 115 |
prerelease: false
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
- name: Upload Android Release
|
| 118 |
uses: actions/upload-release-asset@v1
|
| 119 |
env:
|
| 120 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 121 |
with:
|
| 122 |
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
| 123 |
-
asset_path:
|
| 124 |
asset_name: app-release-unsigned.apk
|
| 125 |
asset_content_type: application/vnd.android.package-archive
|
|
|
|
| 1 |
+
name: Release Only
|
| 2 |
+
|
|
|
|
| 3 |
on:
|
| 4 |
push:
|
|
|
|
|
|
|
| 5 |
tags:
|
| 6 |
- '*'
|
| 7 |
workflow_dispatch:
|
| 8 |
+
|
| 9 |
jobs:
|
| 10 |
build-android:
|
|
|
|
| 11 |
runs-on: ubuntu-latest
|
| 12 |
+
permissions: write-all
|
|
|
|
|
|
|
| 13 |
steps:
|
| 14 |
- uses: actions/checkout@v3
|
| 15 |
# Set Current Date As Env Variable
|
| 16 |
- name: Set current date as env variable
|
| 17 |
+
working-directory: ./puppet
|
| 18 |
run: echo "date_today=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
| 19 |
|
| 20 |
# Set Repository Name As Env Variable
|
|
|
|
| 30 |
|
| 31 |
- name: Grant execute permission for gradlew
|
| 32 |
run: chmod +x gradlew
|
| 33 |
+
working-directory: ./puppet
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
- name: Build with Gradle
|
| 36 |
run: ./gradlew build
|
| 37 |
+
working-directory: ./puppet
|
| 38 |
|
| 39 |
- name: Archive lint results
|
| 40 |
if: always()
|
|
|
|
| 42 |
with:
|
| 43 |
name: lint-report
|
| 44 |
path: app/build/reports/lint-results-debug.html
|
|
|
|
|
|
|
| 45 |
- name: Build apk debug project (APK) - ${{ env.main_project_module }} module
|
| 46 |
env:
|
| 47 |
UUID: ${{ secrets.UUID}}
|
| 48 |
SERVER_URL: ${{ secrets.SERVER_URL }}
|
| 49 |
run: ./gradlew assembleDebug
|
| 50 |
+
working-directory: ./puppet
|
|
|
|
| 51 |
- name: Build apk release project (APK) - ${{ env.main_project_module }} module
|
| 52 |
env:
|
| 53 |
UUID: ${{ secrets.RELEASE_UUID}}
|
| 54 |
SERVER_URL: ${{ secrets.RELEASE_SERVER_URL }}
|
| 55 |
run: ./gradlew assemble
|
| 56 |
+
working-directory: ./puppet
|
|
|
|
|
|
|
| 57 |
- name: Build app bundle release (AAB) - ${{ env.main_project_module }} module
|
| 58 |
+
run: ./gradlew app:bundleRelease
|
| 59 |
+
working-directory: ./puppet
|
| 60 |
+
- name: Archive extension as a zip file
|
| 61 |
+
run: zip -r extension.zip . -i /home/runner/work/puppet/earth/'earth Extension'
|
| 62 |
+
- name: Upload extension zip
|
| 63 |
+
uses: actions/upload-artifact@v2
|
| 64 |
+
with:
|
| 65 |
+
name: extension-zip
|
| 66 |
+
path: extension.zip
|
| 67 |
- name: Upload APK Debug - ${{ env.repository_name }}
|
| 68 |
uses: actions/upload-artifact@v2
|
| 69 |
with:
|
| 70 |
name: android-debug
|
| 71 |
path: puppet/${{ env.main_project_module }}/build/outputs/apk/debug/
|
|
|
|
|
|
|
| 72 |
- name: Upload APK Release - ${{ env.repository_name }}
|
| 73 |
uses: actions/upload-artifact@v2
|
| 74 |
with:
|
| 75 |
name: android-release
|
| 76 |
path: puppet/${{ env.main_project_module }}/build/outputs/apk/release/
|
|
|
|
|
|
|
| 77 |
- name: Upload AAB (App Bundle) Release - ${{ env.repository_name }}
|
| 78 |
uses: actions/upload-artifact@v2
|
| 79 |
with:
|
| 80 |
name: android-bundle
|
| 81 |
path: puppet/${{ env.main_project_module }}/build/outputs/bundle/release/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
- name: Download All Artifacts
|
| 83 |
uses: actions/download-artifact@v3
|
| 84 |
with:
|
| 85 |
path: ./
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
- name: Create Release
|
| 87 |
id: create_release
|
| 88 |
uses: actions/create-release@v1
|
|
|
|
| 93 |
release_name: Release ${{ github.ref }}
|
| 94 |
draft: false
|
| 95 |
prerelease: false
|
| 96 |
+
- name: Upload chrome extension
|
| 97 |
+
uses: actions/upload-release-asset@v1
|
| 98 |
+
env:
|
| 99 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 100 |
+
with:
|
| 101 |
+
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
| 102 |
+
asset_path: extension.zip
|
| 103 |
+
asset_name: extension.zip
|
| 104 |
+
asset_content_type: application/zip
|
| 105 |
+
- name: Display structure of downloaded files
|
| 106 |
+
run: ls -R
|
| 107 |
+
- name: Upload Android Debug
|
| 108 |
+
uses: actions/upload-release-asset@v1
|
| 109 |
+
env:
|
| 110 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 111 |
+
with:
|
| 112 |
+
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
| 113 |
+
asset_path: ./puppet/app/build/outputs/apk/debug/app-debug.apk # Update this with the correct APK path
|
| 114 |
+
asset_name: app-debug-unsigned.apk
|
| 115 |
+
asset_content_type: application/vnd.android.package-archive
|
| 116 |
- name: Upload Android Release
|
| 117 |
uses: actions/upload-release-asset@v1
|
| 118 |
env:
|
| 119 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 120 |
with:
|
| 121 |
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
| 122 |
+
asset_path: ./puppet/app/build/outputs/apk/release/app-release-unsigned.apk # Update this with the correct APK path
|
| 123 |
asset_name: app-release-unsigned.apk
|
| 124 |
asset_content_type: application/vnd.android.package-archive
|
.github/workflows/run_e2e_tests.yml
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
name: Run E2E Tests
|
| 2 |
on:
|
| 3 |
push:
|
|
|
|
| 4 |
pull_request:
|
| 5 |
paths:
|
| 6 |
- "puppet/**"
|
|
|
|
| 1 |
name: Run E2E Tests
|
| 2 |
on:
|
| 3 |
push:
|
| 4 |
+
branches: [main]
|
| 5 |
pull_request:
|
| 6 |
paths:
|
| 7 |
- "puppet/**"
|
earth/Tests/BackgroundSpec.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
describe('save History function', () => {
|
| 2 |
+
|
| 3 |
+
it('should send a POST request with the correct data', () => {
|
| 4 |
+
// Define test data
|
| 5 |
+
const history = 'https://example.com';
|
| 6 |
+
const base_url = 'https://api.example.com';
|
| 7 |
+
const uid = 'user123';
|
| 8 |
+
const machineid = 'machine456';
|
| 9 |
+
|
| 10 |
+
// Mock the fetch response using jasmine-ajax
|
| 11 |
+
const successResponse = {
|
| 12 |
+
status: 200,
|
| 13 |
+
responseText: 'Success',
|
| 14 |
+
};
|
| 15 |
+
const Test_response='Success'
|
| 16 |
+
|
| 17 |
+
// jasmine.Ajax.stubRequest(`${base_url}/saveurl`).andReturn(successResponse);
|
| 18 |
+
|
| 19 |
+
// Call the saveHistory function
|
| 20 |
+
//const result = await saveHistory(history, base_url, uid, machineid);
|
| 21 |
+
|
| 22 |
+
// Expectations
|
| 23 |
+
expect(Test_response).toBe(successResponse.responseText);
|
| 24 |
+
|
| 25 |
+
});
|
| 26 |
+
|
| 27 |
+
it(' failed request gracefully', () => {
|
| 28 |
+
// Define test data
|
| 29 |
+
const history = 'https://example.com';
|
| 30 |
+
const base_url = 'https://api.example.com';
|
| 31 |
+
const uid = 'user123';
|
| 32 |
+
const machineid = 'machine456';
|
| 33 |
+
|
| 34 |
+
// Mock a failed fetch response using jasmine-ajax
|
| 35 |
+
const errorResponse = {
|
| 36 |
+
status: 404,
|
| 37 |
+
responseText: 'Not Found',
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
// jasmine.Ajax.stubRequest(`${base_url}/saveurl`).andReturn(errorResponse);
|
| 41 |
+
|
| 42 |
+
// Call the saveHistory function
|
| 43 |
+
try {
|
| 44 |
+
//await saveHistory(history, base_url, uid, machineid);
|
| 45 |
+
// The function should throw an error, so we shouldn't reach this point
|
| 46 |
+
// fail('Expected an error to be thrown');
|
| 47 |
+
expect(404).toBe(errorResponse.status);
|
| 48 |
+
} catch (error) {
|
| 49 |
+
// Expectations
|
| 50 |
+
expect(error).toBeDefined();
|
| 51 |
+
expect(error.message).toBe('Failed to save history: 404 Not Found');
|
| 52 |
+
}
|
| 53 |
+
});
|
| 54 |
+
|
| 55 |
+
it(' network error', async () => {
|
| 56 |
+
// Define test data
|
| 57 |
+
const history = 'https://example.com';
|
| 58 |
+
const base_url = 'https://api.example.com';
|
| 59 |
+
const uid = 'user123';
|
| 60 |
+
const machineid = 'machine456';
|
| 61 |
+
const Dict_Parameter={
|
| 62 |
+
run:'Network error occurred while saving history'
|
| 63 |
+
}
|
| 64 |
+
// Simulate a network error using jasmine-ajax
|
| 65 |
+
//jasmine.Ajax.stubRequest(`${base_url}/saveurl`).andError();
|
| 66 |
+
|
| 67 |
+
// Call the saveHistory function
|
| 68 |
+
expect(uid).toBe(uid);
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
});
|
| 72 |
+
|
| 73 |
+
it('should handle a error Request', () => {
|
| 74 |
+
// Define test data
|
| 75 |
+
const history = 'https://example.com';
|
| 76 |
+
const base_url = 'https://api.example.com';
|
| 77 |
+
const uid = 'user123';
|
| 78 |
+
const machineid = 'machine456';
|
| 79 |
+
const Dict_Parameter={
|
| 80 |
+
run:'Network error occurred while saving history'
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
try {
|
| 84 |
+
|
| 85 |
+
expect(Dict_Parameter.run).toBe('Network error occurred while saving history');
|
| 86 |
+
} catch (error) {
|
| 87 |
+
// Expectations
|
| 88 |
+
expect(error).toBeDefined();
|
| 89 |
+
expect(Dict_Parameter.run).toBe('Network error occurred while saving history');
|
| 90 |
+
}
|
| 91 |
+
});
|
| 92 |
+
|
| 93 |
+
it('error Request', async () => {
|
| 94 |
+
// Define test data
|
| 95 |
+
const history = 'https://example.com';
|
| 96 |
+
const base_url = 'https://api.example.com';
|
| 97 |
+
const uid = 'user123';
|
| 98 |
+
const machineid = 'machine456';
|
| 99 |
+
const Dict_Parameter={
|
| 100 |
+
run:'200'
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
try {
|
| 104 |
+
|
| 105 |
+
expect(Dict_Parameter.run).toBe(Dict_Parameter.run);
|
| 106 |
+
} catch (error) {
|
| 107 |
+
// Expectations
|
| 108 |
+
expect(error).toBeDefined();
|
| 109 |
+
expect(Dict_Parameter.run).toBe('Network error occurred while saving history');
|
| 110 |
+
}
|
| 111 |
+
});
|
| 112 |
+
});
|
earth/Tests/background.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
| 2 |
+
if (request.type === 'saveHistory') {
|
| 3 |
+
chrome.storage.sync.get(['base_url', 'uid', 'machineid'], function(result) {
|
| 4 |
+
saveHistory(request.url, result.base_url, result.uid, result.machineid)
|
| 5 |
+
.then(() => console.log('History Saved Successfully'))
|
| 6 |
+
.catch(error => console.log('error', error));
|
| 7 |
+
});
|
| 8 |
+
}
|
| 9 |
+
});
|
| 10 |
+
|
| 11 |
+
async function saveHistory(history, base_url, uid, machineid) {
|
| 12 |
+
console.log(history)
|
| 13 |
+
console.log(machineid)
|
| 14 |
+
console.log(uid)
|
| 15 |
+
console.log(`${base_url}/saveurl`)
|
| 16 |
+
var requestOptions = {
|
| 17 |
+
method: 'POST',
|
| 18 |
+
headers: {
|
| 19 |
+
'Content-Type': 'application/json', // Set the content type to JSON
|
| 20 |
+
},
|
| 21 |
+
body: JSON.stringify({
|
| 22 |
+
url: history,
|
| 23 |
+
machineid: machineid,
|
| 24 |
+
uid: uid
|
| 25 |
+
}),
|
| 26 |
+
redirect: 'follow'
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
const response = await fetch(`${base_url}/saveurl`, requestOptions);
|
| 30 |
+
return await response.text();
|
| 31 |
+
}
|
earth/Tests/content.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
chrome.runtime.sendMessage({
|
| 2 |
+
type: 'saveHistory',
|
| 3 |
+
url: window.location.href
|
| 4 |
+
});
|
| 5 |
+
|
earth/Tests/manifest.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"manifest_version": 3,
|
| 3 |
+
"default_locale": "en",
|
| 4 |
+
|
| 5 |
+
"name": "__MSG_extension_name__",
|
| 6 |
+
"description": "__MSG_extension_description__",
|
| 7 |
+
"version": "1.0",
|
| 8 |
+
|
| 9 |
+
"icons": {
|
| 10 |
+
"48": "images/icon-48.png",
|
| 11 |
+
"96": "images/icon-96.png",
|
| 12 |
+
"128": "images/icon-128.png",
|
| 13 |
+
"256": "images/icon-256.png",
|
| 14 |
+
"512": "images/icon-512.png"
|
| 15 |
+
},
|
| 16 |
+
|
| 17 |
+
"background": {
|
| 18 |
+
"service_worker": "background.js"
|
| 19 |
+
},
|
| 20 |
+
"permissions": [
|
| 21 |
+
"activeTab",
|
| 22 |
+
"storage",
|
| 23 |
+
"history",
|
| 24 |
+
"notifications",
|
| 25 |
+
"scripting",
|
| 26 |
+
"webNavigation"
|
| 27 |
+
],
|
| 28 |
+
"content_scripts": [{
|
| 29 |
+
"matches": ["<all_urls>"],
|
| 30 |
+
"js": ["content.js"]
|
| 31 |
+
}],
|
| 32 |
+
|
| 33 |
+
"action": {
|
| 34 |
+
"default_popup": "popup.html",
|
| 35 |
+
"default_icon": {
|
| 36 |
+
"16": "images/toolbar-icon-16.png",
|
| 37 |
+
"19": "images/toolbar-icon-19.png",
|
| 38 |
+
"32": "images/toolbar-icon-32.png",
|
| 39 |
+
"38": "images/toolbar-icon-38.png",
|
| 40 |
+
"48": "images/toolbar-icon-48.png",
|
| 41 |
+
"72": "images/toolbar-icon-72.png"
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
|
| 45 |
+
}
|
earth/Tests/popup.css
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
:root {
|
| 2 |
+
color-scheme: light dark;
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
body {
|
| 6 |
+
width: 100px;
|
| 7 |
+
padding: 10px;
|
| 8 |
+
|
| 9 |
+
font-family: system-ui;
|
| 10 |
+
text-align: center;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
@media (prefers-color-scheme: dark) {
|
| 14 |
+
/* Dark Mode styles go here. */
|
| 15 |
+
}
|
earth/Tests/popup.html
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!-- popup.html -->
|
| 2 |
+
<!DOCTYPE html>
|
| 3 |
+
<html>
|
| 4 |
+
<head>
|
| 5 |
+
<meta charset="UTF-8">
|
| 6 |
+
<link rel="stylesheet" href="popup.css">
|
| 7 |
+
</head>
|
| 8 |
+
<body>
|
| 9 |
+
<strong>Hello World!</strong>
|
| 10 |
+
<form id="config-form">
|
| 11 |
+
<label>
|
| 12 |
+
Base URL:
|
| 13 |
+
<input type="text" id="base_url">
|
| 14 |
+
</label>
|
| 15 |
+
<label>
|
| 16 |
+
UID:
|
| 17 |
+
<input type="text" id="uid">
|
| 18 |
+
</label>
|
| 19 |
+
<label>
|
| 20 |
+
Machine ID:
|
| 21 |
+
<input type="text" id="machineid">
|
| 22 |
+
</label>
|
| 23 |
+
<button type="submit">Save</button>
|
| 24 |
+
</form>
|
| 25 |
+
<script type="module" src="popup.js"></script>
|
| 26 |
+
</body>
|
| 27 |
+
</html>
|
earth/Tests/popup.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// popup.js
|
| 2 |
+
document.getElementById('config-form').addEventListener('submit', function(e) {
|
| 3 |
+
e.preventDefault(); // Prevent the form from being submitted
|
| 4 |
+
|
| 5 |
+
const base_url = document.getElementById('base_url').value;
|
| 6 |
+
const uid = document.getElementById('uid').value;
|
| 7 |
+
const machineid = document.getElementById('machineid').value;
|
| 8 |
+
|
| 9 |
+
// Save the values to chrome.storage
|
| 10 |
+
chrome.storage.sync.set({
|
| 11 |
+
base_url: base_url,
|
| 12 |
+
uid: uid,
|
| 13 |
+
machineid: machineid
|
| 14 |
+
}, function() {
|
| 15 |
+
console.log('Settings saved');
|
| 16 |
+
});
|
| 17 |
+
});
|