-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chrome extension build script, doc, and fixes
- Loading branch information
Showing
43 changed files
with
209 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const axios = require('axios'); | ||
const cheerio = require('cheerio'); | ||
|
||
const downloadFile = async (url, filePath) => { | ||
const dir = path.dirname(filePath); | ||
if (!fs.existsSync(dir)) { | ||
console.log(`Creating directory: ${dir}`); | ||
fs.mkdirSync(dir, { recursive: true }); | ||
} | ||
|
||
console.log(`Downloading ${url}...`); | ||
const writer = fs.createWriteStream(filePath); | ||
const response = await axios({ | ||
url, | ||
method: 'GET', | ||
responseType: 'stream' | ||
}); | ||
|
||
response.data.pipe(writer); | ||
return new Promise((resolve, reject) => { | ||
writer.on('finish', () => { | ||
console.log(`Downloaded and saved to ${filePath}`); | ||
resolve(); | ||
}); | ||
writer.on('error', reject); | ||
}); | ||
}; | ||
|
||
const generateSafeFilename = (url) => { | ||
const urlObj = new URL(url); | ||
let baseName = path.basename(urlObj.pathname); | ||
if (urlObj.search) { | ||
// Handling query strings | ||
baseName += '_' + encodeURIComponent(urlObj.search).replace(/%/g, ''); | ||
} | ||
return baseName; | ||
}; | ||
|
||
const processHTML = async (htmlFilePath) => { | ||
console.log(`Processing HTML file: ${htmlFilePath}`); | ||
const htmlContent = fs.readFileSync(htmlFilePath, 'utf8'); | ||
const $ = cheerio.load(htmlContent); | ||
|
||
// Handle script tags | ||
const scriptTags = $('script[src]'); | ||
for (let i = 0; i < scriptTags.length; i++) { | ||
const src = scriptTags[i].attribs.src; | ||
if (src.startsWith('http')) { | ||
const filename = generateSafeFilename(src); | ||
const localPath = `./local-libs/${filename}`; | ||
try { | ||
await downloadFile(src, localPath); | ||
$(scriptTags[i]).attr('src', localPath); | ||
} catch (error) { | ||
console.error(`Error downloading ${src}: ${error.message}`); | ||
} | ||
} | ||
} | ||
|
||
// Handle link tags for CSS | ||
const linkTags = $('link[rel="stylesheet"]'); | ||
for (let i = 0; i < linkTags.length; i++) { | ||
const href = linkTags[i].attribs.href; | ||
if (href && href.startsWith('http')) { | ||
const filename = generateSafeFilename(href); | ||
const localPath = `./local-libs/${filename}`; | ||
try { | ||
await downloadFile(href, localPath); | ||
$(linkTags[i]).attr('href', localPath); | ||
} catch (error) { | ||
console.error(`Error downloading ${href}: ${error.message}`); | ||
} | ||
} | ||
} | ||
|
||
const modifiedHtml = $.html(); | ||
const newHtmlFilePath = './chrome_index.html'; | ||
fs.writeFileSync(newHtmlFilePath, modifiedHtml); | ||
console.log(`Created modified HTML file: ${newHtmlFilePath}`); | ||
}; | ||
|
||
processHTML('./index.html').catch(error => { | ||
console.error(`An error occurred: ${error.message}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-251 KB
.../app/public/img/screenshots/collect-import-analyze-screenshot-ionic-qm-text.png
Binary file not shown.
File renamed without changes
File renamed without changes
Binary file added
BIN
+552 KB
.../dfda-1/public/app/public/img/screenshots/reminder-inbox-screenshot-no-text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,7 @@ | |
}, | ||
"background": { | ||
"scripts": [ | ||
"qmChromeBackground.js" | ||
"js/qmChrome.js" | ||
], | ||
"persistent": true | ||
} | ||
|
9 changes: 9 additions & 0 deletions
9
apps/dfda-1/public/app/public/test_generated_background_page.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html><head></head><body> | ||
<script src="data/qmStates.js"></script> | ||
<script src="lib/q/q.js"></script> | ||
<script src="custom-lib/bugsnag.js"></script> | ||
<script src="js/qmLogger.js"></script> | ||
<script src="js/qmHelpers.js"></script> | ||
<script src="js/qmChrome.js"></script> | ||
</body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Browser Extension | ||
|
||
By using the Browser Extension, you can track your mood, symptoms, or any outcome you want to optimize in a fraction of a second using a unique popup interface. | ||
|
||
![Chrome Extension](browser-extension.png) | ||
|
||
# 💻 Code | ||
|
||
For development, you need to copy manifest-chrome.json into manifest.json and then load the [apps/dfda-1/public/app/public](../../../apps/dfda-1/public/app/public) folder as an unpacked extension in Chrome. | ||
|
||
[👉 Code here...](../../../apps/dfda-1/public/app/public) | ||
|
||
# 🛟 Support | ||
|
||
If you have any questions or need help, please [create an issue](https://github.com/decentralized-fda/decentralized-fda/issues/new) instead of emailing us so that others can benefit from the discussion. |
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added
BIN
+20.7 KB
...s/data-analysis/correlation-over-various-duration-of-action-hyperparameters.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Oops, something went wrong.