liuyuqi 5 years ago
parent
commit
0f13d1c28c
5 changed files with 64 additions and 11 deletions
  1. 15 0
      Extension/css/styles.css
  2. 11 9
      Extension/js/background.js
  3. 13 0
      Extension/js/popup.js
  4. 11 2
      Extension/manifest.json
  5. 14 0
      Extension/popup.html

+ 15 - 0
Extension/css/styles.css

@@ -0,0 +1,15 @@
+/* main styles */
+* {
+    font-family: 'Segoe UI';
+}
+
+h1 {
+    font-weight: 600;
+    font-size: .9em;
+}
+
+p {
+    font-weight: 500;
+    font-size: .8em;
+    margin-bottom: 10px;  
+}

+ 11 - 9
Extension/js/background.js

@@ -1,11 +1,13 @@
-function onError(error) {
-  console.log(`Error: ${error}`);
-}
+// function onError(error) {
+//   console.log(`Error: ${error}`);
+// }
 
-browser.windows.getAll().then((windowInfoArray) => {
-    for (currentWindow of windowInfoArray) {
-        browser.windows.update(currentWindow.id, {state: "fullscreen"});
-    }
-}, onError);
+// browser.windows.getAll().then((windowInfoArray) => {
+//     for (currentWindow of windowInfoArray) {
+//         browser.windows.update(currentWindow.id, {state: "fullscreen"});
+//     }
+// }, onError);
 
-console.log("错误!!!!");
+browser.windows.update(browser.windows.WINDOW_ID_CURRENT,{state:"fullscreen"});
+
+console.log("test!!!!");

+ 13 - 0
Extension/js/popup.js

@@ -0,0 +1,13 @@
+// get the buttons by id
+let start = document.getElementById('btn_start');
+let stop = document.getElementById('btn_stop');
+
+start.onclick = function() {
+	browser.windows.update(browser.windows.WINDOW_ID_CURRENT,{state:"fullscreen"});
+	console.log("test start!!!!");
+};
+
+stop.onclick = function() {
+	browser.windows.update(browser.windows.WINDOW_ID_CURRENT,{state:"normal"});
+	console.log("test stop!!!!");
+};

+ 11 - 2
Extension/manifest.json

@@ -8,10 +8,19 @@
     "48": "images/color-changer48.png"
   },
   "permissions": [
-    "tabs"
+    "tabs",
+    "<all_urls>"
   ], 
+  "browser_action": {
+    "default_icon": {
+        "20": "images/color-changer25.png",
+        "40": "images/color-changer48.png"
+    },
+    "default_title": "EDGE FULLSCREEN",
+    "default_popup": "popup.html"
+  },
   "background": {
     "scripts": ["js/background.js"],
-    "persistent": true
+    "persistent": false
   }
 }

+ 14 - 0
Extension/popup.html

@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <link rel="stylesheet" type="text/css" href="css/styles.css" />
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+  </head>
+  <body>
+    <h1>Creating a Microsoft Edge Extension</h1>
+    <p>Full Screen</p>
+    <button id="btn_start">Start</button>
+    <button id="btn_stop">Stop</button>
+    <script src="js/popup.js"></script>
+  </body>
+</html>