From c6e3ea9fc510a22ee5c548cd1894e6fae3a54423 Mon Sep 17 00:00:00 2001
From: Matt Baer
Date: Mon, 28 Aug 2017 18:48:24 -0400
Subject: [PATCH] Add extension settings + option to remove dickbar
Closes #2
---
background.js | 11 +++++++++++
manifest.json | 6 +++++-
options.html | 45 +++++++++++++++++++++++++++++++++++++++++++++
options.js | 26 ++++++++++++++++++++++++++
4 files changed, 87 insertions(+), 1 deletion(-)
create mode 100644 options.html
create mode 100644 options.js
diff --git a/background.js b/background.js
index 85d2654..c10c0fe 100644
--- a/background.js
+++ b/background.js
@@ -15,9 +15,20 @@ var makeReadable = function() {
}
};
+var hideDickbar = function() {
+ document.querySelector('.js-postShareWidget').style.display = 'none';
+ document.querySelector('footer > .container:first-child').style.display = 'none';
+};
+
// Only run this on Medium sites.
// Ensure that by checking for in the document
var metaCheck = document.head.querySelector('meta[property="al:ios:app_name"]');
if (metaCheck != null && metaCheck.content == "Medium") {
makeReadable();
+
+ chrome.storage.sync.get(null, function(items) {
+ if (items.hideDickbar) {
+ hideDickbar();
+ }
+ });
}
diff --git a/manifest.json b/manifest.json
index 61995d0..b24d1cd 100644
--- a/manifest.json
+++ b/manifest.json
@@ -5,6 +5,10 @@
"description": "Neutralizes annoying parts of the Medium reading experience so it's more enjoyable to read things.",
"version": "1.0",
+ "options_ui": {
+ "page": "options.html",
+ "chrome_style": true
+ },
"icons": {
"128": "icon.png"
},
@@ -12,7 +16,7 @@
"default_icon": "icon.png"
},
"permissions": [
- "https://*/*"
+ "storage", "https://*/*"
],
"content_scripts": [
{
diff --git a/options.html b/options.html
new file mode 100644
index 0000000..de09b5e
--- /dev/null
+++ b/options.html
@@ -0,0 +1,45 @@
+
+
+
+ Make Medium Readable Again Settings
+
+
+
+
+ Personal Preferences
+
+
+
+
+
+ Defaults
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/options.js b/options.js
new file mode 100644
index 0000000..27de99d
--- /dev/null
+++ b/options.js
@@ -0,0 +1,26 @@
+// Saves options to chrome.storage
+function save_options() {
+ var hideDickbar = document.getElementById('dickbar').checked;
+ chrome.storage.sync.set({
+ hideDickbar: hideDickbar
+ }, function() {
+ // Update status to let user know options were saved.
+ var status = document.getElementById('status');
+ status.textContent = 'Readability improved! (Settings saved.)';
+ setTimeout(function() {
+ status.textContent = '';
+ }, 2500);
+ });
+}
+
+// Restores select box and checkbox state using the preferences
+// stored in chrome.storage.
+function restore_options() {
+ chrome.storage.sync.get({
+ hideDickbar: false
+ }, function(items) {
+ document.getElementById('dickbar').checked = items.hideDickbar;
+ });
+}
+document.addEventListener('DOMContentLoaded', restore_options);
+document.getElementById('save').addEventListener('click', save_options);