Skip to content

Commit

Permalink
Updating to v1.1
Browse files Browse the repository at this point in the history
This version includes a new options page to allow users to choose to remove additional things
  • Loading branch information
Fogest committed Jan 8, 2016
1 parent 3398e18 commit 7a21f45
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 3 deletions.
Binary file modified Email-Print-Page-Cleaner.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Gmail-Print-Page-Cleaner
========================

Removes some things from the Gmail print email page, mainly removing the Gmail logo at the top.
Will remove user chosen elements from Gmails print view.
34 changes: 33 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
$("div.bodycontainer table tbody img[alt='Gmail']").parent().hide();
//Check if it a print page
if(document.title.startsWith('Gmail')) {
//Get user options
var hideGmailLogo = true;
var hideEmail = false;
var hideSubject = false;
var hideContactDetails = false;
chrome.storage.sync.get(['hideGmailLogo', 'hideEmail', 'hideSubject', 'hideContactDetails'], function(items) {
if(typeof items.hideGmailLogo !== 'undefined') hideGmailLogo = items.hideGmailLogo;
if(typeof items.hideEmail !== 'undefined') hideEmail = items.hideEmail;
if(typeof items.hideSubject !== 'undefined') hideSubject = items.hideSubject;
if(typeof items.hideContactDetails !== 'undefined') hideContactDetails = items.hideContactDetails;
hide();
})

function hide() {
if(hideGmailLogo) {
$("div.bodycontainer table tbody img[alt='Gmail']").parent().hide();
}
if(hideEmail) {
$("body > div > table").siblings("hr").hide();
$("body > div > table").hide();
}
if(hideSubject) {
$("body > div > div > table:nth-child(1)").next().hide();
$("body > div > div > table:nth-child(1)").hide();
}
if(hideContactDetails) {
$("table.message > tbody > tr:nth-child(1)").hide();
$("table.message > tbody > tr:nth-child(2)").hide();
}
}
}
8 changes: 7 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
"manifest_version": 2,

"name": "Email Print Page Cleaner",
"version": "1.0.2",
"version": "1.1",
"description": "Removes some things from the Email print pages (ie: Gmail) to make them cleaner",

"options_ui": {
"page": "options.html",
"chrome_style": true
},

"permissions": [
"storage",
"https://mail.google.com/"
],

Expand Down
36 changes: 36 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<title>My Test Extension Options</title>
<style>
body: { padding: 10px; }
</style>
</head>

<body>
<label>
<input type="checkbox" id="hideGmailLogo">
Hide Gmail logo?
</label>
<br/>
<label>
<input type="checkbox" id="hideEmail">
Hide your email address?
</label>
<br/>
<label>
<input type="checkbox" id="hideSubject">
Hide the subject?
</label>
<br/>
<label>
<input type="checkbox" id="hideContactDetails">
Hide the senders details? <i>(This is an experimental settings and can sometimes make email conversations hard to follow)</i>
</label>
<br/>
<div id="status"></div>
<button id="save">Save</button>

<script src="options.js"></script>
</body>
</html>
40 changes: 40 additions & 0 deletions options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Saves options to chrome.storage.sync.
function save_options() {
var hideGmailLogo = document.getElementById('hideGmailLogo').checked;
var hideEmail = document.getElementById('hideEmail').checked;
var hideSubject = document.getElementById('hideSubject').checked;
var hideContactDetails = document.getElementById('hideContactDetails').checked;
alert("Here");
chrome.storage.sync.set({
hideGmailLogo: hideGmailLogo,
hideEmail: hideEmail,
hideSubject: hideSubject,
hideContactDetails: hideContactDetails
}, function() {
// Update status to let user know options were saved.
var status = document.getElementById('status');
status.textContent = 'Options saved.';
setTimeout(function() {
status.textContent = 'Saved';
}, 750);
});
}

// Restores select box and checkbox state using the preferences
// stored in chrome.storage.
function restore_options() {
alert();
chrome.storage.sync.get({
hideGmailLogo: true,
hideEmail: false,
hideSubject: false,
hideContactDetails: false
}, function(items) {
document.getElementById('hideGmailLogo').checked = items.hideGmailLogo;
document.getElementById('hideEmail').checked = items.hideEmail;
document.getElementById('hideSubject').checked = items.hideSubject;
document.getElementById('hideContactDetails').checked = items.hideContactDetails;
});
}
document.addEventListener('DOMContentLoaded', restore_options);
document.getElementById('save').addEventListener('click',save_options);

0 comments on commit 7a21f45

Please sign in to comment.