Skip to content

Commit

Permalink
Set up extension with simple CSS injection
Browse files Browse the repository at this point in the history
  • Loading branch information
kallepersson committed Sep 15, 2018
0 parents commit 2632719
Show file tree
Hide file tree
Showing 15 changed files with 177 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@

.DS_Store
in-min.js
8 changes: 8 additions & 0 deletions RESEARCH.md
@@ -0,0 +1,8 @@
##Classes
.aeN is sidebar
.L3 is compose button


##Things to do
- Listen to hash changes, update header with title and color
- Pinned is now Starred. Add switch for toggling this in the current view
12 changes: 12 additions & 0 deletions clone.sh
@@ -0,0 +1,12 @@
#!/bin/bash
while sleep 1; do
echo "(function(){" > in-min.js
echo "const _css = \`" >> in-min.js
cat in.css >> in-min.js
echo "body::after { content: '" >> in-min.js
echo $(date +"%H:%M:%S") >> in-min.js
echo "';}" >> in-min.js
echo "\`;" >> in-min.js
cat in.js >> in-min.js
echo "})();" >> in-min.js
done
Binary file added img/128-store.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon-128.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon-16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon-19.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon-256.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon-38.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon-48.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions in.css
@@ -0,0 +1,46 @@
/* Compose button */
.aeN .z0> {
height: auto;
}
.aeN .z0>.L3 {
background-color: #d23f31;
height: 56px;
width: 56px;
border-radius:50%;
position: relative;
box-shadow: 0 0 4px rgba(0,0,0,.14), 0 4px 8px rgba(0,0,0,.28);
position: fixed;
right: 15px;
bottom: 15px;
z-index: 100;
text-indent: -9999px;
overflow: hidden;
padding: 0;
}

.aeN .z0>.L3::before /* Compose Icon */ ,
.aeG /* Footer stats */ ,
.gb_Be img.gb_Wa /* Gmail logo */,
.gb_Ra .gb_Sa /* GSuite Logo */
{
display: none !important;
}

/* GSuite button */
.gb_Ra {
border: 0 !important;
width: auto !important;
}

/* Debug element */
body::after {
display: block;
position: fixed;
bottom: 25px;
left: 0;
z-index: 9999;
background: rgba(0,0,0,0.3);
color: #fff;
font-family: monospace;
font-size: 14;
}
21 changes: 21 additions & 0 deletions in.js
@@ -0,0 +1,21 @@
const _styleElement = document.createElement("style");
_styleElement.innerText = _css;

const init = (evt) => {
document.head.appendChild(_styleElement);
console.log("ready", _styleElement.parentNode)
}

const handleHashChange = (evt) => {
console.log("#", window.location.hash);
document.body.dataset.hash = window.location.hash;
}

window.addEventListener("hashchange", handleHashChange);


if (document.head) {
init();
} else {
document.addEventListener("DOMContentLoaded", init);
}
26 changes: 26 additions & 0 deletions manifest.json
@@ -0,0 +1,26 @@
{
"name": "Inbox theme for Gmail",
"description" : "Makes Gmail look and behave like Inbox",
"homepage_url": "http://flowapps.co/inboxnostalgia",
"author": "Kalle Persson",
"version": "1.0.0",
"icons": {
"16": "img/icon-256.png",
"19": "img/icon-256.png",
"38": "img/icon-256.png",
"48": "img/icon-256.png",
"128": "img/icon-256.png",
"256": "img/icon-256.png"
},
"manifest_version": 2,
"content_scripts": [
{
"matches": [
"https://mail.google.com/*"
],
"js": [
"in-min.js"
]
}
]
}
24 changes: 24 additions & 0 deletions options.html
@@ -0,0 +1,24 @@
<!doctype html>
<html>
<head>
<style type="text/css">
img {
cursor: pointer;
display: block;
margin: 0 0 5px 0;
}

.selected {
outline: 2px solid #76a7fa;
}
</style>
</head>
<body>

<img src="img/theme-default.png" id="default" alt="Default" title="Default">
<img src="img/theme-dark.png" id="dark" alt="Dark" title="Dark">
<img src="img/theme-sepia.png" id="sepia" alt="Sepia" title="Sepia">

<script type="text/javascript" src="options.js"></script>
</body>
</html>
37 changes: 37 additions & 0 deletions options.js
@@ -0,0 +1,37 @@
function restoreOptions() {
chrome.storage.sync.get({
theme: "default"
}, function(items) {
selectTheme(items.theme)
});
}

function selectTheme(theme) {
let elm = document.getElementById(theme);
if (!elm) {
return;
}

let selectedElement = document.querySelector(".selected");
if (selectedElement) {
selectedElement.classList.remove("selected");
}

elm.className = "selected";

chrome.storage.sync.set({
theme: theme,
}, function() {
console.log("saved", theme);
});
}

window.addEventListener("click", function(evt) {
if (evt.target.tagName != "IMG") {
return;
}

selectTheme(evt.target.id);
});

document.addEventListener("DOMContentLoaded", restoreOptions);

0 comments on commit 2632719

Please sign in to comment.