~soapdog/webextension-buntimer-as-a-sidebar

d970a6e1ef7a3431b14a9510eef177044b1b7d73 — Andre Alves Garzia 2 years ago 0f6dce6 master
initial version
8 files changed, 108 insertions(+), 10 deletions(-)

M README.md
M icons/icon512.png
M index.html
A loader.html
A main.js
M manifest.json
A setup.html
A setup.js
M README.md => README.md +3 -3
@@ 1,12 1,12 @@
# Twitter as a Sidebar
# Buntimer as a Sidebar

## What it does

Allows it to run [Twitter lite](https://mobile.twitter.com) as a sidebar on your browser.
Allows it to run [Buntimer 2020](https://buntimer2020.netlify.com/?soapy) as a sidebar on your browser.

## Screenshot

![screenshot](screenshot.png)

## Icon
[Icon by Neil Heinsworth](https://www.iconfinder.com/icons/107056/blue_twitter_icon#size=512)
\ No newline at end of file
[Icon by Nick Roach](https://www.iconfinder.com/icons/1055090/clock_time_timer_icon)
\ No newline at end of file

M icons/icon512.png => icons/icon512.png +0 -0
M index.html => index.html +6 -5
@@ 1,10 1,11 @@
<!doctype html>
<html>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Twitter Lite Loading...</title>
    <meta http-equiv="refresh" content="0; url=https://mobile.twitter.com/">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Buntimer 2020</title>
</head>
<body>
    <h1>Loading...</h1>
    <script src="main.js"></script>
</body>
</html>
\ No newline at end of file

A loader.html => loader.html +10 -0
@@ 0,0 1,10 @@
<!doctype html>
<html>
<head>
    <title>Buntimer Lite Loading...</title>
    <meta http-equiv="refresh" content="0; url=https://buntimer2020.netlify.com/?soapy">
</head>
<body>
    <h1>Loading...</h1>
</body>
</html>
\ No newline at end of file

A main.js => main.js +19 -0
@@ 0,0 1,19 @@
let username = localStorage.getItem("username")
let whichURL = localStorage.getItem("whichURL") || "private"
let url;

let privateURL = "https://buntimer2020.netlify.com/?"
let syncURL = "https://buntimer2020.firebaseapp.com/?"


if (whichURL === "private") {
    url = privateURL
} else {
    url = syncURL
}

if (!username) {
    location = "/setup.html"
} else {
    location = `${url}${username}`
}
\ No newline at end of file

M manifest.json => manifest.json +15 -2
@@ 1,8 1,8 @@
{

  "manifest_version": 2,
  "name": "Twitter as a Sidebar",
  "description": "Displays a sidebar that lets you talk to your friends using Twitter.",
  "name": "Buntimer as a Sidebar",
  "description": "Displays a sidebar that lets you user buntimer 2020.",
  "version": "2.0",
  "applications": {
    "gecko": {


@@ 14,6 14,19 @@
    "512": "icons/icon512.png"
  },

  "options_ui": {
    "page": "setup.html",
    "browser_style": true
  },

  "sidebar_action": {
    "default_icon": {
      "512": "icons/icon512.png"
    },
    "default_title" : "Buntimer 2020",
    "default_panel": "index.html"
  },

  "permissions": [
    "<all_urls>",
    "storage", 

A setup.html => setup.html +29 -0
@@ 0,0 1,29 @@
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Buntimer 2020 setup</title>
</head>

<body>
    <h1>Buntimer 2020 setup</h1>
    <form id="setup">
        <p>What kind of timers do you want to use?</p>
        <div>
            <input type="radio" id="private" name="whichURL" value="private">
            <label for="private">Private</label>
        </div>
        <div>
            <input type="radio" id="sync" name="whichURL" value="sync">
            <label for="private">Synchronized</label>
        </div>
        <p>What is your username? Make it unique!</p>
        <input type="text" name="username" id="username"><br><br>
        <input type="submit" value="Save">
    </form>
    <script src="setup.js"></script>
</body>

</html>
\ No newline at end of file

A setup.js => setup.js +26 -0
@@ 0,0 1,26 @@
let form = document.getElementById("setup")

form.addEventListener("submit", ev => {
    ev.preventDefault()

    let data = new FormData(form)
    let username = data.get("username")
    let whichURL = data.get("whichURL")

    localStorage.setItem("username", username)
    localStorage.setItem("whichURL", whichURL)
    location = "/index.html"
})

let data = new FormData(form)

document.getElementById("username").value = localStorage.getItem("username") || ""

let whichURL = localStorage.getItem("whichURL") || "private"

if (whichURL === "private") {
    document.getElementById("private").checked = true
} else {
    document.getElementById("sync").checked = true
}