this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: apply eslint/prettier

This was mostly was removing unused variables.

The only significant change was moving the getDomainName and checkForDID function definitions to the body root.

+103 -92
+42 -33
background.js
··· 1 1 // Set up cross-browser compatibility 2 - const runtime = typeof browser !== 'undefined' ? browser.runtime : chrome.runtime; 3 - const tabs = typeof browser !== 'undefined' ? browser.tabs : chrome.tabs; 4 - const storage = typeof browser !== 'undefined' ? browser.storage.local : chrome.storage.local; 5 - const action = typeof browser !== 'undefined' ? browser.browserAction : chrome.action; 2 + const runtime = 3 + typeof browser !== "undefined" ? browser.runtime : chrome.runtime 4 + const tabs = typeof browser !== "undefined" ? browser.tabs : chrome.tabs 5 + const storage = 6 + typeof browser !== "undefined" ? browser.storage.local : chrome.storage.local 7 + const action = 8 + typeof browser !== "undefined" ? browser.browserAction : chrome.action 6 9 7 10 // On extension installation, check if privacy consent was already accepted and show it if not 8 11 runtime.onInstalled.addListener(() => { 9 12 storage.get("privacyConsentAccepted", ({ privacyConsentAccepted }) => { 10 - if (typeof privacyConsentAccepted === "undefined" || !privacyConsentAccepted) { 11 - tabs.create({ url: "privacy_consent.html" }); 13 + if ( 14 + typeof privacyConsentAccepted === "undefined" || 15 + !privacyConsentAccepted 16 + ) { 17 + tabs.create({ url: "privacy_consent.html" }) 12 18 } 13 - }); 14 - }); 19 + }) 20 + }) 15 21 16 22 // If the message 'SHOW_CONSENT' is received, open the privacy consent tab 17 - runtime.onMessage.addListener((message, sender, sendResponse) => { 18 - if (message.type === 'SHOW_CONSENT') { 19 - tabs.create({ url: "privacy_consent.html" }); 23 + runtime.onMessage.addListener((message) => { 24 + if (message.type === "SHOW_CONSENT") { 25 + tabs.create({ url: "privacy_consent.html" }) 20 26 } 21 - }); 27 + }) 22 28 23 29 // Map to store tabs with DIDs 24 - const tabsWithDID = new Map(); 30 + const tabsWithDID = new Map() 25 31 26 32 // URL of the Bluesky Web Applications 27 - const bskyAppUrl = 'https://staging.bsky.app'; 33 + const bskyAppUrl = "https://staging.bsky.app" 28 34 29 35 // Function to set the extension icon 30 36 function setIcon(tabId, iconName) { 31 - action.setIcon({ path: iconName, tabId }); 37 + action.setIcon({ path: iconName, tabId }) 32 38 } 33 39 34 40 // On extension installation, set the icon to gray for all tabs 35 41 runtime.onInstalled.addListener(() => { 36 42 tabs.query({}, (tabs) => { 37 - tabs.forEach((tab) => setIcon(tab.id, 'logo48_gray.png')); 38 - }); 39 - }); 43 + tabs.forEach((tab) => setIcon(tab.id, "logo48_gray.png")) 44 + }) 45 + }) 40 46 41 47 // When a message is received from the DNS check, set the icon color to blue. 42 - runtime.onMessage.addListener((message, sender, sendResponse) => { 48 + runtime.onMessage.addListener((message, sender) => { 43 49 if (message.type === "DID_FOUND") { 44 - setIcon(sender.tab.id, "logo48.png"); 45 - tabsWithDID.set(sender.tab.id, message.did); 50 + setIcon(sender.tab.id, "logo48.png") 51 + tabsWithDID.set(sender.tab.id, message.did) 46 52 } else { 47 - setIcon(sender.tab.id, "logo48_gray.png"); 48 - tabsWithDID.delete(sender.tab.id); 53 + setIcon(sender.tab.id, "logo48_gray.png") 54 + tabsWithDID.delete(sender.tab.id) 49 55 } 50 - }); 56 + }) 51 57 52 58 // Open the consent page if it hasn't been accepted and the user clicks on the extension icon 53 - action.onClicked.addListener((tab) => { 59 + action.onClicked.addListener(() => { 54 60 storage.get("privacyConsentAccepted", ({ privacyConsentAccepted }) => { 55 - if (typeof privacyConsentAccepted === "undefined" || !privacyConsentAccepted) { 56 - tabs.create({ url: "privacy_consent.html" }); 61 + if ( 62 + typeof privacyConsentAccepted === "undefined" || 63 + !privacyConsentAccepted 64 + ) { 65 + tabs.create({ url: "privacy_consent.html" }) 57 66 } 58 - }); 59 - }); 67 + }) 68 + }) 60 69 61 70 // When the extension icon is clicked, open the profile page if there's a DID 62 71 action.onClicked.addListener((tab) => { 63 - const did = tabsWithDID.get(tab.id); 72 + const did = tabsWithDID.get(tab.id) 64 73 if (did) { 65 - const newUrl = `${bskyAppUrl}/profile/${did}`; 66 - tabs.create({ url: newUrl }); 74 + const newUrl = `${bskyAppUrl}/profile/${did}` 75 + tabs.create({ url: newUrl }) 67 76 } 68 - }); 77 + })
+51 -50
content.js
··· 1 1 // Set up cross-browser compatibility 2 - const runtime = typeof browser !== 'undefined' ? browser.runtime : chrome.runtime; 3 - const tabs = typeof browser !== 'undefined' ? browser.tabs : chrome.tabs; 4 - const storage = typeof browser !== 'undefined' ? browser.storage.local : chrome.storage.local; 2 + const runtime = 3 + typeof browser !== "undefined" ? browser.runtime : chrome.runtime 4 + const storage = 5 + typeof browser !== "undefined" ? browser.storage.local : chrome.storage.local 5 6 6 - // Main function to perform actions, but only if the privacy consent has been accepted 7 - function performAction(privacyConsentAccepted) { 8 - // If the user has accepted the privacy consent 9 - if (privacyConsentAccepted) { 10 - // Function to get the domain name from the current hostname 11 - function getDomainName() { 12 - const hostname = window.location.hostname; 13 - return hostname.replace(/^www\./, ''); 14 - } 7 + // Function to get the domain name from the current hostname 8 + function getDomainName() { 9 + const hostname = window.location.hostname 10 + return hostname.replace(/^www\./, "") 11 + } 15 12 16 - // Function to check for a DID in the domain's TXT records 17 - async function checkForDID(domain) { 18 - // We use Google's DNS over HTTPS API to resolve the TXT record 19 - const response = await fetch( 20 - `https://dns.google/resolve?name=_atproto.${domain}&type=TXT` 21 - ); 22 - const data = await response.json(); 13 + // Function to check for a DID in the domain's TXT records 14 + async function checkForDID(domain) { 15 + // We use Google's DNS over HTTPS API to resolve the TXT record 16 + const response = await fetch( 17 + `https://dns.google/resolve?name=_atproto.${domain}&type=TXT` 18 + ) 19 + const data = await response.json() 23 20 24 - // We use the TXT record type to avoid CORS issues 25 - const records = data?.Answer?.filter((record) => record.type === 16) || []; 21 + // We use the TXT record type to avoid CORS issues 22 + const records = data?.Answer?.filter((record) => record.type === 16) || [] 26 23 27 - // We filter out all records that are not TXT records 28 - const didRecord = records.find((record) => 29 - record.data.includes("did=did:plc:") 30 - ); 24 + // We filter out all records that are not TXT records 25 + const didRecord = records.find((record) => 26 + record.data.includes("did=did:plc:") 27 + ) 31 28 32 - // We return the DID if we found one 33 - return didRecord ? didRecord.data.replace("did=", "") : null; 34 - } 29 + // We return the DID if we found one 30 + return didRecord ? didRecord.data.replace("did=", "") : null 31 + } 35 32 36 - // We check for a DID on the current domain 37 - ;(async function () { 38 - const domain = getDomainName() 39 - const did = await checkForDID(domain) 33 + // Main function to perform actions, but only if the privacy consent has been accepted 34 + function performAction(privacyConsentAccepted) { 35 + // If the user has accepted the privacy consent 36 + if (privacyConsentAccepted) { 37 + // We check for a DID on the current domain 38 + ;(async function () { 39 + const domain = getDomainName() 40 + const did = await checkForDID(domain) 40 41 41 - if (did) { 42 - runtime.sendMessage({ type: "DID_FOUND", did }) 43 - } else { 44 - runtime.sendMessage({ type: "DID_NOT_FOUND" }) 45 - } 46 - })(); 42 + if (did) { 43 + runtime.sendMessage({ type: "DID_FOUND", did }) 44 + } else { 45 + runtime.sendMessage({ type: "DID_NOT_FOUND" }) 46 + } 47 + })() 47 48 48 - // We listen for messages from the background script 49 - runtime.onMessage.addListener((message, sender, sendResponse) => { 50 - if (message.type === "GET_DID") { 51 - checkForDID(getDomainName()) 52 - .then((did) => sendResponse({ did })) 53 - .catch(() => sendResponse({ did: null })) 54 - return true // Indicate that the response will be sent asynchronously. 55 - } 56 - }); 49 + // We listen for messages from the background script 50 + runtime.onMessage.addListener((message, sender, sendResponse) => { 51 + if (message.type === "GET_DID") { 52 + checkForDID(getDomainName()) 53 + .then((did) => sendResponse({ did })) 54 + .catch(() => sendResponse({ did: null })) 55 + return true // Indicate that the response will be sent asynchronously. 56 + } 57 + }) 57 58 } else { 58 59 // Do nothing since the consent form has not been accepted. 59 - return; 60 + return 60 61 } 61 62 } 62 63 63 64 // Get the user's privacy consent from the storage and perform actions accordingly 64 65 storage.get("privacyConsentAccepted", ({ privacyConsentAccepted }) => { 65 - performAction(privacyConsentAccepted); 66 - }); 66 + performAction(privacyConsentAccepted) 67 + })
+10 -9
privacy_consent.js
··· 1 1 // Set up cross-browser compatibility 2 - const runtime = typeof browser !== 'undefined' ? browser.runtime : chrome.runtime; 3 - const storage = typeof browser !== 'undefined' ? browser.storage.local : chrome.storage.local; 4 - const management = typeof browser !== 'undefined' ? browser.management : chrome.management; 2 + const storage = 3 + typeof browser !== "undefined" ? browser.storage.local : chrome.storage.local 4 + const management = 5 + typeof browser !== "undefined" ? browser.management : chrome.management 5 6 6 7 document.getElementById("accept").addEventListener("click", function () { 7 - storage.set({ privacyConsentAccepted: true }); 8 - window.close(); 9 - }); 8 + storage.set({ privacyConsentAccepted: true }) 9 + window.close() 10 + }) 10 11 11 - document.getElementById("decline").addEventListener("click", function () { 12 - management.uninstallSelf({ showConfirmDialog: true }); 13 - }); 12 + document.getElementById("decline").addEventListener("click", function () { 13 + management.uninstallSelf({ showConfirmDialog: true }) 14 + })