Explorar el Código

Initial commit

Pjotir hace 1 año
commit
086e75cc66

+ 13 - 0
.hintrc

@@ -0,0 +1,13 @@
+{
+  "extends": [
+    "development"
+  ],
+  "hints": {
+    "axe/text-alternatives": [
+      "default",
+      {
+        "document-title": "off"
+      }
+    ]
+  }
+}

+ 60 - 0
assets/css/popup.css

@@ -0,0 +1,60 @@
+@font-face {
+    font-family: Eurostile;
+    src: url(../fonts/eurostile.ttf)
+}
+
+html {
+    font-family: Eurostile, Arial, Helvetica, sans-serif;
+    color: white;
+}
+
+body {
+    background-color: #191818;
+    margin: 0;
+    width: 500px;
+    height: 500px;
+}
+
+.container {
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    height: 90vh;
+    width: 90vw;
+    margin: 5vw;
+}
+
+.table-container {
+    width: 100%;
+    overflow-y: auto;
+    flex-grow: 1;
+}
+
+table {
+    width: 100%;
+    background-color: #242424;
+}
+
+button {
+    font-family: Eurostile, Arial, Helvetica, sans-serif;
+    font-size: large;
+    width: 100%;
+    flex-basis: 40px;
+    margin-bottom: 5px;
+    border-radius: 5px;
+    background-color: lightcoral;
+    color: black;
+}
+
+button:hover {
+    background-color: rgb(238, 104, 104);
+    cursor: pointer;
+}
+
+tbody>tr:hover {
+    background-color: #2c2c2c;
+}
+
+th {
+    text-align: start;
+}

BIN
assets/fonts/eurostile.ttf


+ 32 - 0
assets/html/popup.html

@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="en">
+    <head>
+        <meta charset="UTF-8">
+        <meta name="viewport" content="width=device-width, initial-scale=1">
+        <link href="../css/popup.css" rel="stylesheet">
+    </head>
+    <body>
+        <div class="container">
+            <button class="button-primary" id="grabbutton">Grab Delivery
+                Invoice</button>
+            <button class="button-primary" id="inputbutton">Input to
+                Pizmet</button>
+            <div class="table-container">
+                <table>
+                    <thead>
+                        <tr>
+                            <th>Item #</th>
+                            <th>Quantity</th>
+                            <th>Price</th>
+                            <th>Total</th>
+                        </tr>
+                    </thead>
+                    <tbody id="tablebody">
+
+                    </tbody>
+                </table>
+            </div>
+        </div>
+        <script src="../js/background.js"></script>
+    </body>
+</html>

BIN
assets/img/favicon.ico


+ 24 - 0
assets/js/background.js

@@ -0,0 +1,24 @@
+document.getElementById("grabbutton").addEventListener("click", function () {
+    browser.tabs.query({ active: true, currentWindow: true }).then(tabs => {
+        browser.tabs
+            .sendMessage(tabs[0].id, "get")
+            .then(response => {
+                tablebody = document.getElementById("tablebody");
+                tablebody.innerHTML = "";
+                response.forEach(row => {
+                    let tr = document.createElement("tr");
+                    const cellids = [0, 4, 6, 7];
+                    for (let i = 0; i < cellids.length; i++) {
+                        let td = document.createElement("td");
+                        td.textContent = row[cellids[i]];
+                        if (i == 1) td.textContent = td.textContent.substring(13);
+                        tr.appendChild(td);
+                    }
+                    tablebody.appendChild(tr);
+                });
+            });
+    })
+        .catch(error => {
+            console.log(error);
+        });
+});

+ 13 - 0
assets/js/contentscript_pfg.js

@@ -0,0 +1,13 @@
+function getInvoice() {
+    return Array.from(document.getElementsByClassName("css-8tkdem")).map(row => {
+        return Array.from(row.children).map(container => {
+            return container.textContent;
+        })
+    });
+}
+
+browser.runtime.onMessage.addListener(function (message, sender, sendResponse) {
+    if (message === "get") {
+        sendResponse(getInvoice());
+    }
+});

+ 0 - 0
assets/js/contentscript_pizmet.js


+ 38 - 0
manifest.json

@@ -0,0 +1,38 @@
+{
+    "name": "Pizmet Deliverator",
+    "description": "Automatically enter food deliveries into Pizmet",
+    "version": "0.1",
+    "manifest_version": 2,
+    "permissions": [
+        "activeTab"
+    ],
+    "icons": {
+        "48": "assets/img/favicon.ico"
+    },
+    "content_scripts": [
+        {
+            "matches": [
+                "https://cloud.pizmet.com/*"
+            ],
+            "js": [
+                "assets/js/contentscript_pizmet.js"
+            ]
+        },
+        {
+            "matches": [
+                "https://*.customerfirstsolutions.com/*"
+            ],
+            "js": [
+                "assets/js/contentscript_pfg.js"
+            ]
+        }
+    ],
+    "browser_action": {
+        "default_popup": "assets/html/popup.html"
+    },
+    "background": {
+        "scripts": [
+            "assets/js/background.js"
+        ]
+    }
+}