1
0
mirror of https://github.com/thebaer/MMRA synced 2024-11-13 10:11:01 +00:00

Add extension settings + option to remove dickbar

Closes #2
This commit is contained in:
Matt Baer 2017-08-28 18:48:24 -04:00
parent e9d2103db9
commit c6e3ea9fc5
4 changed files with 87 additions and 1 deletions

View File

@ -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 <meta property="al:ios:app_name" content="Medium"> in the document <head />
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();
}
});
}

View File

@ -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": [
{

45
options.html Normal file
View File

@ -0,0 +1,45 @@
<!DOCTYPE html>
<html>
<head>
<title>Make Medium Readable Again Settings</title>
<style>
body: { padding: 10px; }
label {
display: block;
margin: 1em 0;
}
#status {
font-size: 1.1em;
}
</style>
</head>
<body>
<h2>Personal Preferences</h2>
<label>
<input type="checkbox" id="dickbar"> Hide sharing dickbar
</label>
<hr />
<h2>Defaults</h2>
<label>
<input type="checkbox" checked="checked" disabled="disabled"> Un-stick top navigation bar
</label>
<label>
<input type="checkbox" checked="checked" disabled="disabled"> Hide bottom <em>Get Updates</em> bar
</label>
<hr />
<p id="status"></p>
<button id="save">Save</button>
<script src="options.js"></script>
</body>
</html>

26
options.js Normal file
View File

@ -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);