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

Migrate to manifest v3 #56

Merged
merged 2 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 0 additions & 12 deletions report_ai/background.js

This file was deleted.

10 changes: 9 additions & 1 deletion report_ai/content.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global chrome */

let theText
let theText = ''
const toSelect = ['p', 'h1', 'h2', 'h3', 'h5', 'h6', 'li'] // tags to extract texts from

// extracting the data
Expand Down Expand Up @@ -247,3 +247,11 @@ const pageMeta = {

// saving the data in local storage
chrome.storage.local.set({ key: pageMeta })
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
console.log(sender.tab
? 'from a content script:' + sender.tab.url
: 'from the extension')
request.to === 'content_script' && sendResponse({ pageMeta })
}
)
11 changes: 4 additions & 7 deletions report_ai/manifest.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
{
"manifest_version": 2,
"manifest_version": 3,
"name": "Report.AI",
"description": "5-Star Rating, Summary, Report n much more..",
"version": "3.1",
"browser_action": {
"action": {
"default_popup": "index.html"
},
"permissions": ["storage", "http://127.0.0.1:5000/*", "background", "tabs"],
"background": {
"scripts": ["./background.js", "./popup.js"],
"persistent": false
},
"permissions": ["storage", "tabs"],
"host_permissions": ["http://127.0.0.1:5000/*"],
"icons": {
"16": "assets/icon.png",
"32": "assets/icon.png",
Expand Down
13 changes: 10 additions & 3 deletions report_ai/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function logger (result) {
}

btn1.onclick = () => {
if (result && result.key && result.key.freqWord) {
if (result?.key?.freqWord) {
for (let i = 0; i < 10; i++) {
const s = document.createElement('span')
s.innerHTML = result.key.freqWord[i]
Expand Down Expand Up @@ -193,8 +193,15 @@ function saveEntry (rating, url) {
})
}

// fetching the local data and calling the logger
chrome.storage.local.get(['key'], logger)
(async () => {
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true })
console.log(tab)
const response = await chrome.tabs.sendMessage(tab.id, {
to: 'content_script'
})
console.log(response)
logger({ key: response.pageMeta })
})()

function checkConnectionSignal () {
const element = document.getElementById('connectionSignal')
Expand Down
4 changes: 3 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
ROBERTA = os.environ.get("BART", None)
headersBart = {"Authorization": BART}
headersRoberta = {"Authorization": ROBERTA}
MONGO_URI = os.environ.get("mongo_uri","mongodb+srv://admin:[email protected]/")
MONGO_URI = os.environ.get(
"mongo_uri", "mongodb+srv://admin:[email protected]/"
)
client = MongoClient(MONGO_URI, server_api=ServerApi("1"))
try:
client.admin.command("ping")
Expand Down