-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement basic create, upsert, update, delete operations
- Loading branch information
s-a-sen
committed
Jan 25, 2023
1 parent
2a340f6
commit 192eacb
Showing
7 changed files
with
165 additions
and
11 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "Мониторим переключение вкладок", | ||
"description": "Расширение для мониторинга вкладок", | ||
"version": "1.0", | ||
"manifest_version": 3, | ||
"permissions": ["tabs", "scripting", "notifications"], | ||
"action": { | ||
"default_icon": { | ||
"16": "/images/get_started16.png", | ||
"32": "/images/get_started32.png", | ||
"48": "/images/get_started48.png", | ||
"128": "/images/get_started128.png" | ||
} | ||
}, | ||
"icons": { | ||
"16": "/images/get_started16.png", | ||
"32": "/images/get_started32.png", | ||
"48": "/images/get_started48.png", | ||
"128": "/images/get_started128.png" | ||
}, | ||
"host_permissions": [ | ||
"http://0.0.0.0:8000" | ||
], | ||
"background": { | ||
"service_worker": "service-worker.js", | ||
"type": "module" | ||
} | ||
} |
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,71 @@ | ||
let activeTabId, lastUrl, lastTitle; | ||
|
||
function getTabInfo(tabId) { | ||
chrome.tabs.get(tabId, function(tab) { | ||
if(lastUrl != tab.url || lastTitle != tab.title) { | ||
console.log(lastUrl = tab.url, lastTitle = tab.title); | ||
// sendTab(); | ||
} | ||
}); | ||
} | ||
|
||
chrome.tabs.onActivated.addListener(function(activeInfo) { | ||
getTabInfo(activeTabId = activeInfo.tabId); | ||
}); | ||
|
||
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { | ||
if(activeTabId == tabId) { | ||
getTabInfo(tabId); | ||
} | ||
}); | ||
|
||
// | ||
// chrome.runtime.onInstalled.addListener(async () => { | ||
// console.log(await getCurrentTab()); | ||
// chrome.notifications.create('NOTFICATION_ID', { | ||
// type: 'basic', | ||
// iconUrl: 'path', | ||
// title: 'notification title', | ||
// message: 'notification message', | ||
// priority: 2 | ||
// }); | ||
// }); | ||
// | ||
function sendTab() { | ||
fetch('http://0.0.0.0:8000', { | ||
method: 'post', | ||
body: "{}" | ||
}).then(function(r) { | ||
return r.json(); | ||
}).then(function(data) { | ||
console.log(data); | ||
}); | ||
} | ||
// // | ||
// // function handleActivated(activeInfo) { | ||
// // console.log(`Tab ${activeInfo.tabId} was activated`); | ||
// // chrome.notifications.create('NOTFICATION_ID', { | ||
// // type: 'basic', | ||
// // iconUrl: 'path', | ||
// // title: 'notification title', | ||
// // message: 'notification message', | ||
// // priority: 2 | ||
// // }) | ||
// // } | ||
// | ||
// browser.tabs.onActivated.addListener(() => { | ||
// chrome.notifications.create('NOTFICATION_ID', { | ||
// type: 'basic', | ||
// iconUrl: 'path', | ||
// title: 'notification title', | ||
// message: 'notification message', | ||
// priority: 2 | ||
// }) | ||
// }); | ||
// | ||
async function getCurrentTab() { | ||
let queryOptions = { active: true, lastFocusedWindow: true }; | ||
// `tab` will either be a `tabs.Tab` instance or `undefined`. | ||
let [tab] = await chrome.tabs.query(queryOptions); | ||
return tab; | ||
} |
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