Browse Source

Add button to install a script from URL

Gerald 10 years ago
parent
commit
e2452453d1

+ 10 - 0
README.md

@@ -13,3 +13,13 @@ Multiple language
   have empty `message`s.
   You may then check out `src/_locales/en/messages.json` for the English version
   and translate it.
+
+Development
+---
+Run command below:
+
+``` sh
+$ gulp
+```
+
+Then you can load the extension from `dist/`.

+ 9 - 1
src/_locales/cs/messages.json

@@ -417,5 +417,13 @@
   "hintInjectModeAdvanced": {
     "description": "Hint to explain the advanced injection mode.",
     "message": "Pracuje na většině stránek, současně se jedná o hack."
+  },
+  "hintInputURL": {
+    "description": "Hint for a prompt box to input URL of a user script.",
+    "message": ""
+  },
+  "buttonInstallFromURL": {
+    "description": "Button to ask for URL of a user script.",
+    "message": ""
   }
-}
+}

+ 9 - 1
src/_locales/de/messages.json

@@ -417,5 +417,13 @@
   "hintInjectModeAdvanced": {
     "description": "Hint to explain the advanced injection mode.",
     "message": ""
+  },
+  "hintInputURL": {
+    "description": "Hint for a prompt box to input URL of a user script.",
+    "message": ""
+  },
+  "buttonInstallFromURL": {
+    "description": "Button to ask for URL of a user script.",
+    "message": ""
   }
-}
+}

+ 9 - 1
src/_locales/en/messages.json

@@ -417,5 +417,13 @@
   "hintInjectModeAdvanced": {
     "description": "Hint to explain the advanced injection mode.",
     "message": "Works in most pages, actually a hack"
+  },
+  "hintInputURL": {
+    "description": "Hint for a prompt box to input URL of a user script.",
+    "message": "Input URL:"
+  },
+  "buttonInstallFromURL": {
+    "description": "Button to ask for URL of a user script.",
+    "message": "Install from URL"
   }
-}
+}

+ 9 - 1
src/_locales/pl/messages.json

@@ -417,5 +417,13 @@
   "hintInjectModeAdvanced": {
     "description": "Hint to explain the advanced injection mode.",
     "message": ""
+  },
+  "hintInputURL": {
+    "description": "Hint for a prompt box to input URL of a user script.",
+    "message": ""
+  },
+  "buttonInstallFromURL": {
+    "description": "Button to ask for URL of a user script.",
+    "message": ""
   }
-}
+}

+ 9 - 1
src/_locales/ru/messages.json

@@ -417,5 +417,13 @@
   "hintInjectModeAdvanced": {
     "description": "Hint to explain the advanced injection mode.",
     "message": ""
+  },
+  "hintInputURL": {
+    "description": "Hint for a prompt box to input URL of a user script.",
+    "message": ""
+  },
+  "buttonInstallFromURL": {
+    "description": "Button to ask for URL of a user script.",
+    "message": ""
   }
-}
+}

+ 9 - 1
src/_locales/zh/messages.json

@@ -417,5 +417,13 @@
   "hintInjectModeAdvanced": {
     "description": "Hint to explain the advanced injection mode.",
     "message": "不走寻常路,可以在大部分页面成功注入"
+  },
+  "hintInputURL": {
+    "description": "Hint for a prompt box to input URL of a user script.",
+    "message": "请输入地址:"
+  },
+  "buttonInstallFromURL": {
+    "description": "Button to ask for URL of a user script.",
+    "message": "通过地址安装"
   }
-}
+}

+ 1 - 0
src/options/templates/tab-installed.html

@@ -1,6 +1,7 @@
 <header>
   <button id=bNew data-i18n=buttonNew></button>
   <button id=bUpdate data-i18n=buttonUpdateAll></button>
+  <button id=bURL data-i18n=buttonInstallFromURL></button>
   <div class="pull-right">
     <a href=https://greasyfork.org/scripts target=_blank data-i18n=anchorGetMoreScripts></a>
   </div>

+ 9 - 0
src/options/views/tab-installed.js

@@ -5,6 +5,7 @@ var MainTab = BaseView.extend({
   events: {
     'click #bNew': 'newScript',
     'click #bUpdate': 'updateAll',
+    'click #bURL': 'installFromURL',
   },
   initialize: function () {
     var _this = this;
@@ -60,4 +61,12 @@ var MainTab = BaseView.extend({
   updateAll: function () {
     _.sendMessage({cmd: 'CheckUpdateAll'});
   },
+  installFromURL: function () {
+    var url = prompt(_.i18n('hintInputURL'));
+    if (~url.indexOf('://')) {
+      chrome.tabs.create({
+        url: chrome.extension.getURL('/options/index.html') + '#confirm/' + encodeURIComponent(url),
+      });
+    }
+  },
 });