Skip to content
This repository has been archived by the owner on Aug 27, 2019. It is now read-only.

Commit

Permalink
Beta v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Apr 13, 2017
1 parent c5e4075 commit b5eda88
Show file tree
Hide file tree
Showing 60 changed files with 395 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web-ext-artifacts
109 changes: 109 additions & 0 deletions src/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/* global browser */
const ABOUT_PAGES = [
["about:", "firefox", false],
["about:about", "cog", false],
["about:accounts", "user", false],
["about:addons", "plugin", false],
["about:blank", "page-white", true],
["about:buildconfig", "building", false],
["about:cache", "drive", false],
["about:checkerboard", "chart-line", false],
["about:config", "wrench", false],
["about:crashes", "error", false],
["about:credits", "vcard", false],
["about:debugging", "script-lightning", false],
["about:devtools-toolbox", "wrench-orange", false],
["about:downloads", "drive-down", false],
["about:healthreport", "heart", false],
["about:home", "house", true],
["about:license", "report", true],
["about:logo", "picture-empty", true],
["about:memory", "memory", false],
["about:mozilla", "world", false],
["about:networking", "world-network", false],
["about:newtab", "tab", false],
["about:performance", "server-lightning", false],
["about:plugins", "plugin", false],
["about:preferences", "options-wrench", false],
["about:privatebrowsing", "lock", false],
["about:profiles", "group", false],
["about:rights", "receipt", true],
["about:robots", "user-red", false],
["about:serviceworkers", "script-gear", false],
["about:sessionrestore", "lightning", false],
["about:support", "help", false],
["about:sync-log", "page-refresh", false],
["about:sync-tabs", "tabs-refresh", false],
["about:telemetry", "chart-curve", false],
["about:webrtc", "phone", false],
["about:welcomeback", "emoticon-smile", false]
];

/**
* @param {type} message
* @param {type} resolve
* @param {type} privileged
* @returns {undefined}
*/
function registerPage(message, resolve, privileged) {
let data = [];
data[0] = String(message.page);
data[1] = String(message.icon !== undefined ? message.icon : "");
data[2] = !Boolean(message.privileged);

let isNew = true;
if (privileged) {
for (let i = 0; i < ABOUT_PAGES.length; i++) {
let d = ABOUT_PAGES[i];
if (data[0].localeCompare(d[0], {sensitivity: "accent", numeric: true}) === 0) {
ABOUT_PAGES.slice(i, 1);
}
}
} else {
for (let d in ABOUT_PAGES) {
if (data[0].localeCompare(d[0], {sensitivity: "accent", numeric: true}) === 0) {
isNew = false;
break;
}
}
}

if (isNew) {
ABOUT_PAGES.push(data);
ABOUT_PAGES.sort((a, b) => {
return a[0].localeCompare(b[0], {
sensitivity: "accent",
numeric: true
})
});
}
resolve(isNew);
return;
}

browser.runtime.onMessage.addListener((message, sender, resolve) => {
let messageType = String(message.type);
switch (messageType) {
case "registerPage": {
registerPage(message, resolve, true);
break;
} case "getPages": {
resolve({pages: ABOUT_PAGES.slice()});
return;
} default: {
throw new Error("Invalid message type: " + messageType);
}
}
});

browser.runtime.onMessageExternal.addListener((message, sender, resolve) => {
let messageType = String(message.type);
switch (messageType) {
case "registerPage": {
registerPage(message, resolve, false);
break;
} default: {
throw new Error("Invalid message type: " + messageType);
}
}
});
Binary file added src/icons/128/cog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/16/cog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/24/cog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/brick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/building.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/chart-curve.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/chart-line.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/cog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/drive-down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/drive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/emoticon-smile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/firefox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/group.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/heart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/house.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/lightning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/lock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/memory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/monitor-terminal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/options-wrench.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/page-refresh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/page-white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/256/phone.png
Binary file added src/icons/256/picture-empty.png
Binary file added src/icons/256/plugin.png
Binary file added src/icons/256/receipt.png
Binary file added src/icons/256/report.png
Binary file added src/icons/256/script-gear.png
Binary file added src/icons/256/script-lightning.png
Binary file added src/icons/256/server-lightning.png
Binary file added src/icons/256/tab.png
Binary file added src/icons/256/tabs-refresh.png
Binary file added src/icons/256/thunderbird.png
Binary file added src/icons/256/user-red.png
Binary file added src/icons/256/user.png
Binary file added src/icons/256/vcard.png
Binary file added src/icons/256/world-network.png
Binary file added src/icons/256/world.png
Binary file added src/icons/256/wrench-orange.png
Binary file added src/icons/256/wrench.png
Binary file added src/icons/32/cog.png
Binary file added src/icons/48/cog.png
Binary file added src/icons/64/cog.png
Binary file added src/icons/72/cog.png
Binary file added src/icons/96/cog.png
12 changes: 12 additions & 0 deletions src/icons/about.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" ?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<!-- This file contains mata data about the icons -->
<Description>
<creator>Michael Buckley</creator>
<id>[email protected]</id>
<name>Pastel SVG Icons</name>
<version>1.2</version>
<description>An Icon set based on famfamfam.</description>
<homepageURL>http://codefisher.org/pastel-svg/</homepageURL>
</Description>
</RDF>
4 changes: 4 additions & 0 deletions src/icons/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The Pastel SVG icon set Created by Michael Buckley is licensed under the:

Creative Commons Attribution NonCommercial Share Alike 4.0
http://creativecommons.org/licenses/by-nc-sa/4.0/
49 changes: 49 additions & 0 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"applications": {
"gecko": {
"id": "about-button@exe-boss",
"strict_min_version": "52.0"
}
},

"manifest_version": 2,
"name": "Firefox about:about Button",
"version": "0.1.0b1",
"author": "ExE Boss",
"description": "A Firefox exclusive WebExtension to quickly open about:* pages",

"permissions": [
"storage"
],
"icons": {
"16": "icons/16/cog.png",
"24": "icons/24/cog.png",
"32": "icons/32/cog.png",
"48": "icons/48/cog.png",
"64": "icons/64/cog.png",
"72": "icons/72/cog.png",
"96": "icons/96/cog.png",
"128":"icons/128/cog.png",
"256":"icons/256/cog.png"
},

"background": {
"scripts": ["background.js"]
},
"browser_action": {
"browser_style": true,
"default_icon": {
"16": "icons/16/cog.png",
"24": "icons/24/cog.png",
"32": "icons/32/cog.png",
"48": "icons/48/cog.png",
"64": "icons/64/cog.png",
"72": "icons/72/cog.png",
"96": "icons/96/cog.png",
"128":"icons/128/cog.png",
"256":"icons/256/cog.png"
},
"default_title": "about:about",
"default_popup": "popup/popup.html"
}
}
14 changes: 14 additions & 0 deletions src/options/options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Firefox about:about Button Options</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="options.js"></script>
</head>
<body>
<div>
<input id="showDisabledButtons" type="checkbox" checked>Show disabled buttons
</div>
</body>
</html>
13 changes: 13 additions & 0 deletions src/options/options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* global browser */

function restore_options() {
browser.storage.local.get({
showDisabledButtons: true
}).then((settings) => {
document.getElementById("showDisabledButtons").checked = settings.showDisabledButtons;
}).catch((error) => {
document.getElementById("showDisabledButtons").checked = true;
});
}

document.addEventListener('DOMContentLoaded', () => {restore_options()});
41 changes: 41 additions & 0 deletions src/popup/popup.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

html, body {
overflow-x: hidden !important;
}

body {
margin: 4px !important;
}

button {
width: 100% !important;
text-align: left !important;
white-space: nowrap;
}

button:disabled {
background-color: #CCC !important;
border: solid !important;
border-width: 1px !important;
border-color: #777 !important;
}

#main-table {
width: 100% !important;
margin-right: 16px !important;
border-spacing: 8px !important;
}

a {
text-decoration: none !important;
color: black !important;
}

.icon {
vertical-align: middle !important;
margin-right: 8px !important;
}

.icon.missing {
margin-right: 24px !important;
}
17 changes: 17 additions & 0 deletions src/popup/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>about:about</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="popup.css">
<script src="popup.js"></script>
</head>
<body>
<div id="header"></div>
<main id="main">
<table id="main-table"></table>
</main>
<div id="footer"></div>
</body>
</html>
90 changes: 90 additions & 0 deletions src/popup/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/* global browser */

document.addEventListener('DOMContentLoaded', () => {
browser.storage.onChanged.addListener((changes, areaName) => {
switch (areaName) {
case "local": {
if (changes.showDisabledButtons !== undefined) {
reload();
}
break;
}
}
});
reload();
});

async function reload() {
let footer = document.getElementById("footer");
let table = document.getElementById("main-table");

table.innerHTML = "";
footer.innerHTML = "";

browser.runtime.sendMessage({
type: "getPages"
}).then(async (response) => {
response.showDisabledButtons = await browser.storage.local.get({
showDisabledButtons: true
}).then((settings) => {
return settings.showDisabledButtons;
}).catch((error) => {
console.error(error);
return true;
});
return response;
}).then(async (response) => {
let pages = response.pages;
let showDisabledButtons = response.showDisabledButtons;

if (showDisabledButtons === undefined)
showDisabledButtons = true;
if (!showDisabledButtons) {
footer.appendChild(document.createTextNode("Disabled buttons have been hidden"));
}
pages.forEach((page) => {
let tr = document.createElement("tr");
let td = document.createElement("td");

let button = document.createElement("button");
let img = generateImg(page[1]);
button.setAttribute("type", button);
if (!page[2])
button.setAttribute("disabled", true);
button.appendChild(img);
button.appendChild(document.createTextNode(page[0]));
button.addEventListener("click", (evt) => {
if (page[2]) {
browser.tabs.create({url: page[0]});
} else {
browser.tabs.create({url: "/redirect/redirect.html?dest=" + page[0]});
}
});

if (page[2] || (!page[2] && showDisabledButtons)) {
td.appendChild(button);
tr.appendChild(td);
table.appendChild(tr);
}
});
}).catch(async (error) => {
console.error(error);
});
}

/**
* @param {String} path
* @returns {HTMLImgElement}
*/
function generateImg(path) {
let img = document.createElement("img");
img.setAttribute("class", "icon");
img.setAttribute("width", "16px");
if (path && path.length !== 0) {
// img.setAttribute("src", "/icons/SVG/" + path + ".svg");
img.setAttribute("src", "/icons/256/" + path + ".png");
} else {
img.setAttribute("class", "icon missing");
}
return img;
}
11 changes: 11 additions & 0 deletions src/redirect/redirect.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>about:about</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="redirect.js"></script>
</head>
<body id="body">
</body>
</html>
Loading

0 comments on commit b5eda88

Please sign in to comment.