diff --git a/submissions/Judge This Website/background.js b/submissions/Judge This Website/background.js new file mode 100644 index 00000000..f7bf8f7e --- /dev/null +++ b/submissions/Judge This Website/background.js @@ -0,0 +1,3 @@ +chrome.runtime.onInstalled.addListener(() => { + console.log("Judge This Website extension installed."); +}); diff --git a/submissions/Judge This Website/manifest.json b/submissions/Judge This Website/manifest.json new file mode 100644 index 00000000..0a291770 --- /dev/null +++ b/submissions/Judge This Website/manifest.json @@ -0,0 +1,18 @@ +{ + "manifest_version": 3, + "name": "Judge This Website", + "version": "1.0", + "description": "Let people personally judge the websites they visit.", + "permissions": ["tabs", "storage"], + "action": { + "default_popup": "popup.html", + "default_icon": { + "16": "icons/icon16.png", + "48": "icons/icon48.png", + "128": "icons/icon128.png" + } + }, + "background": { + "service_worker": "background.js" + } +} diff --git a/submissions/Judge This Website/popup.css b/submissions/Judge This Website/popup.css new file mode 100644 index 00000000..2109edb0 --- /dev/null +++ b/submissions/Judge This Website/popup.css @@ -0,0 +1,20 @@ +body { + font-family: Arial, sans-serif; + padding: 10px; + width: 300px; +} + +h1 { + font-size: 18px; + margin-bottom: 10px; +} + +textarea { + width: 100%; +} + +button { + margin-top: 10px; + padding: 5px 10px; + cursor: pointer; +} diff --git a/submissions/Judge This Website/popup.html b/submissions/Judge This Website/popup.html new file mode 100644 index 00000000..46c5c73a --- /dev/null +++ b/submissions/Judge This Website/popup.html @@ -0,0 +1,26 @@ + + + + Judge This Website + + + +

Judge This Website

+
+ + +

+ +

+ + +

Previous Judgment

+ + + + + diff --git a/submissions/Judge This Website/popup.js b/submissions/Judge This Website/popup.js new file mode 100644 index 00000000..cd212a9a --- /dev/null +++ b/submissions/Judge This Website/popup.js @@ -0,0 +1,30 @@ +document.addEventListener('DOMContentLoaded', async () => { + let [tab] = await chrome.tabs.query({ active: true, currentWindow: true }); + let url = new URL(tab.url); + let domain = url.hostname; + + document.getElementById('site').textContent = domain; + + chrome.storage.local.get([domain], (result) => { + if (result[domain]) { + document.getElementById('previous').innerHTML = ` + Judgment: ${result[domain].rating}
+ Comment: ${result[domain].comment} + `; + } else { + document.getElementById('previous').textContent = "No judgment yet."; + } + }); + + document.getElementById('submit').addEventListener('click', () => { + let rating = document.getElementById('rating').value; + let comment = document.getElementById('comment').value; + + let data = { rating, comment }; + + chrome.storage.local.set({ [domain]: data }, () => { + alert('Your judgment has been saved!'); + location.reload(); + }); + }); +});