diff --git a/content/main.js b/content/main.js new file mode 100644 index 0000000..e69de29 diff --git a/content/styles/badges.css b/content/styles/badges.css new file mode 100644 index 0000000..e69de29 diff --git a/content/tweaks/badges.js b/content/tweaks/badges.js new file mode 100644 index 0000000..e69de29 diff --git a/icons/icon-48.png b/icons/icon-48.png new file mode 100644 index 0000000..93d83e0 Binary files /dev/null and b/icons/icon-48.png differ diff --git a/icons/icon-96.png b/icons/icon-96.png new file mode 100644 index 0000000..fbdff3f Binary files /dev/null and b/icons/icon-96.png differ diff --git a/lib/settings.js b/lib/settings.js new file mode 100644 index 0000000..17a79ba --- /dev/null +++ b/lib/settings.js @@ -0,0 +1,46 @@ +(function () { + "use strict"; + + const DEFAULTS = { + enabled: true, + darkMode: "auto", + "light.subredditBgColor": "transparent", + "light.subredditBorderColor": "#c84a20", + "light.subredditTextColor": "#c84a20", + "light.commentsBgColor": "#e0e0e0", + "light.commentsBorderColor": "#4a4a4a", + "light.commentsTextColor": "#4a4a4a", + "dark.subredditBgColor": "transparent", + "dark.subredditBorderColor": "#ff6b3d", + "dark.subredditTextColor": "#ff6b3d", + "dark.commentsBgColor": "#3a3a3a", + "dark.commentsBorderColor": "#888888", + "dark.commentsTextColor": "#cccccc", + subredditColors: {}, + }; + + async function loadSettings() { + const stored = await browser.storage.local.get(null); + return Object.assign({}, DEFAULTS, stored); + } + + async function saveSettings(settings) { + const toStore = {}; + for (const key of Object.keys(settings)) { + if (key in DEFAULTS) { + toStore[key] = settings[key]; + } + } + await browser.storage.local.set(toStore); + } + + async function resetSettings() { + await browser.storage.local.clear(); + } + + window.RedditTweaks = window.RedditTweaks || {}; + window.RedditTweaks.DEFAULTS = DEFAULTS; + window.RedditTweaks.loadSettings = loadSettings; + window.RedditTweaks.saveSettings = saveSettings; + window.RedditTweaks.resetSettings = resetSettings; +})(); diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..249391d --- /dev/null +++ b/manifest.json @@ -0,0 +1,28 @@ +{ + "manifest_version": 2, + "name": "Reddit Tweaks", + "version": "1.0.0", + "description": "Reskins old Reddit post listings with badge-style subreddit and comment indicators.", + "permissions": ["storage", "activeTab"], + "icons": { + "48": "icons/icon-48.png", + "96": "icons/icon-96.png" + }, + "browser_action": { + "default_icon": "icons/icon-48.png", + "default_popup": "popup/popup.html", + "default_title": "Reddit Tweaks Settings" + }, + "content_scripts": [ + { + "matches": ["*://old.reddit.com/*", "*://www.reddit.com/*"], + "css": ["content/styles/badges.css"], + "js": [ + "lib/settings.js", + "content/tweaks/badges.js", + "content/main.js" + ], + "run_at": "document_idle" + } + ] +}