typescripting
This commit is contained in:
@@ -48,7 +48,7 @@ class ResultLinks extends Map {
|
|||||||
getSearchLinks() {
|
getSearchLinks() {
|
||||||
// return an iterator over the nested SearchLink objects
|
// return an iterator over the nested SearchLink objects
|
||||||
const domain_value_iterator = super.values() as MapIterator<Map<string, SearchLink>>
|
const domain_value_iterator = super.values() as MapIterator<Map<string, SearchLink>>
|
||||||
const search_link_iterator = domain_value_iterator.flatMap((domain_map) => {
|
const search_link_iterator = domain_value_iterator.flatMap((domain_map: Map<string, SearchLink>) => {
|
||||||
return domain_map.values()
|
return domain_map.values()
|
||||||
})
|
})
|
||||||
return search_link_iterator
|
return search_link_iterator
|
||||||
@@ -66,14 +66,14 @@ const page_links = new ResultLinks()
|
|||||||
|
|
||||||
function check_links(search_links: SearchLink[]) {
|
function check_links(search_links: SearchLink[]) {
|
||||||
// send a message to background script with a list of URLs to check
|
// send a message to background script with a list of URLs to check
|
||||||
const urls = search_links.map((search_link) => {
|
const urls = search_links.map((search_link: SearchLink) => {
|
||||||
search_link.checked = true
|
search_link.checked = true
|
||||||
return search_link.target
|
return search_link.target
|
||||||
})
|
})
|
||||||
browser.runtime.sendMessage({type: "check", urls: urls.toArray()})
|
browser.runtime.sendMessage({type: "check", urls: urls})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function message_listener(message) {
|
async function message_listener(message: any) {
|
||||||
// handle slop reports returned from the background script
|
// handle slop reports returned from the background script
|
||||||
if(message.type === "check_result") {
|
if(message.type === "check_result") {
|
||||||
if (message.domain) {
|
if (message.domain) {
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ async function insert_slop(domain: string, path: string) {
|
|||||||
|
|
||||||
// is this domain already stored?
|
// is this domain already stored?
|
||||||
const request = slop_store.get(domain)
|
const request = slop_store.get(domain)
|
||||||
request.onsuccess = (event) => {
|
request.onsuccess = () => {
|
||||||
let result = request.result
|
let result = request.result
|
||||||
if (result) {
|
if (result) {
|
||||||
// domain exists, add this path
|
// domain exists, add this path
|
||||||
@@ -188,7 +188,7 @@ async function message_listener(message: any, sender: any) {
|
|||||||
let check_promises = new Array()
|
let check_promises = new Array()
|
||||||
let not_found_local = new Array()
|
let not_found_local = new Array()
|
||||||
|
|
||||||
message.urls.forEach((url) => {
|
message.urls.forEach((url: string) => {
|
||||||
check_promises.push(check_local_slop(url).then(async (result) => {
|
check_promises.push(check_local_slop(url).then(async (result) => {
|
||||||
if (result.slop_domain) {
|
if (result.slop_domain) {
|
||||||
browser.tabs.sendMessage(tabid, { type: "check_result", url: url, result: result })
|
browser.tabs.sendMessage(tabid, { type: "check_result", url: url, result: result })
|
||||||
|
|||||||
@@ -4,6 +4,6 @@
|
|||||||
"outDir": "scripts",
|
"outDir": "scripts",
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"lib": ["ES2020", "DOM"],
|
"lib": ["ES2020", "DOM"],
|
||||||
"inlineSourceMap": true
|
"sourceMap": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user