瀏覽代碼

chore: drop support for older browsers which does not support async functions

Gerald 6 年之前
父節點
當前提交
93a6a58b01
共有 11 個文件被更改,包括 299 次插入307 次删除
  1. 2 1
      .browserslistrc
  2. 1 0
      .eslintrc.js
  3. 0 4
      gulpfile.js
  4. 11 11
      package.json
  5. 9 9
      src/common/polyfills.js
  6. 1 1
      src/injected/content/index.js
  7. 1 1
      src/injected/content/util.js
  8. 3 3
      src/injected/web/index.js
  9. 1 1
      src/manifest.yml
  10. 1 2
      src/popup/index.js
  11. 269 274
      yarn.lock

+ 2 - 1
.browserslistrc

@@ -1 +1,2 @@
-Chrome >= 45
+Chrome >= 55
+Firefox >= 52

+ 1 - 0
.eslintrc.js

@@ -10,6 +10,7 @@ module.exports = {
     },
   },
   rules: {
+    'prefer-object-spread': 'off',
   },
   globals: {
     browser: true,

+ 0 - 4
gulpfile.js

@@ -73,10 +73,6 @@ function manifest() {
     const data = yaml.safeLoad(input);
     // Strip alphabetic suffix
     data.version = pkg.version.replace(/-[^.]*/, '');
-    if (process.env.TARGET === 'firefox') {
-      data.version += 'f';
-      data.applications.gecko.update_url = 'https://violentmonkey.top/static/updates.json';
-    }
     file.path = file.path.replace(/\.yml$/, '.json');
     return JSON.stringify(data);
   }))

+ 11 - 11
package.json

@@ -17,18 +17,18 @@
   },
   "description": "Violentmonkey",
   "devDependencies": {
-    "@babel/register": "^7.5.5",
-    "@gera2ld/plaid": "~1.4.7",
-    "@gera2ld/plaid-vue": "~1.4.0",
-    "@gera2ld/plaid-webpack": "~1.4.8",
-    "cross-env": "^5.0.5",
-    "del": "^5.0.0",
+    "@babel/register": "^7.6.0",
+    "@gera2ld/plaid": "~1.4.12",
+    "@gera2ld/plaid-vue": "~1.4.9",
+    "@gera2ld/plaid-webpack": "~1.4.12",
+    "cross-env": "^6.0.0",
+    "del": "^5.1.0",
     "fancy-log": "^1.3.2",
     "gulp": "^4.0.2",
     "gulp-filter": "^6.0.0",
     "gulp-plumber": "^1.1.0",
     "gulp-uglify": "^3.0.2",
-    "husky": "^3.0.2",
+    "husky": "^3.0.5",
     "js-yaml": "^3.13.1",
     "plugin-error": "^1.0.0",
     "tape": "^4.11.0",
@@ -47,12 +47,12 @@
   "homepage": "https://github.com/violentmonkey/violentmonkey",
   "license": "MIT",
   "dependencies": {
-    "@babel/runtime": "^7.5.5",
-    "codemirror": "^5.48.2",
-    "core-js": "^3.1.4",
+    "@babel/runtime": "^7.6.0",
+    "codemirror": "^5.48.4",
+    "core-js": "^3.2.1",
     "tldjs": "^2.3.1",
     "vue": "^2.6.10",
-    "vueleton": "^1.0.2"
+    "vueleton": "^1.0.3"
   },
   "engines": {
     "node": ">=10"

+ 9 - 9
src/common/polyfills.js

@@ -1,12 +1,12 @@
-import 'core-js/features/object/assign';
-import 'core-js/features/object/values';
-import 'core-js/features/array/includes';
-import 'core-js/features/array/find';
-import 'core-js/features/array/find-index';
-import 'core-js/features/string/includes';
-import 'core-js/features/string/starts-with';
-import 'core-js/features/string/ends-with';
-import 'core-js/features/string/repeat';
+// import 'core-js/features/object/assign'; // Chrome >= 45, Firefox >= 34
+// import 'core-js/features/object/values'; // Chrome >= 54, Firefox >= 47
+// import 'core-js/features/array/includes'; // Chrome >= 47, Firefox >= 43
+// import 'core-js/features/array/find'; // Chrome >= 45, Firefox >= 25
+// import 'core-js/features/array/find-index'; // Chrome >= 45, Firefox >= 25
+// import 'core-js/features/string/includes'; // Chrome >= 41, Firefox >= 40
+// import 'core-js/features/string/starts-with'; // Chrome >= 41, Firefox >= 17
+// import 'core-js/features/string/ends-with'; // Chrome >= 41, Firefox >= 17
+// import 'core-js/features/string/repeat'; // Chrome >= 41, Firefox >= 24
 
 // Must use native Promise for Firefox to work
 // import 'core-js/features/promise';

+ 1 - 1
src/injected/content/index.js

@@ -254,7 +254,7 @@ function injectScript(data) {
     code,
     JSON.stringify(vCallbackId),
   ];
-  const injectedCode = `!${func.toString()}(${args.join(',')})`;
+  const injectedCode = `(${func.toString()})(${args.join(',')});`;
   if (mode === INJECT_CONTENT) {
     sendMessage({
       cmd: 'InjectScript',

+ 1 - 1
src/injected/content/util.js

@@ -13,7 +13,7 @@ export function inject(code, sourceUrl) {
   const id = getUniqId('VM-');
   script.id = id;
   const sourceComment = sourceUrl ? `\n//# sourceURL=${sourceUrl}` : '';
-  script.textContent = `!${removeElement.toString()}(${JSON.stringify(id)});${code}${sourceComment}`;
+  script.textContent = `(${removeElement.toString()})(${JSON.stringify(id)});${code}${sourceComment}`;
   document.documentElement.appendChild(script);
   // in case the script is blocked by CSP
   removeElement(id);

+ 3 - 3
src/injected/web/index.js

@@ -126,7 +126,7 @@ function onLoadScripts(data) {
     const fnId = getUniqId('VMfn');
     const wrapperInit = map(keys, name => `this["${name}"]=${name}`).join(';');
     const codeSlices = [
-      `${wrapperInit};with(this)!function(define,module,exports){`,
+      `${wrapperInit};with(this)((define,module,exports)=>{`,
     ];
     forEach(requireKeys, (key) => {
       const requireCode = data.require[pathMap[key] || key];
@@ -141,9 +141,9 @@ function onLoadScripts(data) {
     });
     push(
       codeSlices,
-      '!function(){',
+      '(()=>{',
       code,
-      '}.call(this)}.call(this);',
+      '})()})();',
     );
     const codeConcat = `function(${keys.join(',')}){${codeSlices.join('\n')}}`;
     const name = script.custom.name || script.meta.name || script.props.id;

+ 1 - 1
src/manifest.yml

@@ -43,6 +43,6 @@ permissions:
   - unlimitedStorage
   - clipboardWrite
 
-applications:
+browser_specific_settings:
   gecko:
     id: '{aecec67f-0d10-4fa7-b7c7-609a2db280cf}'

+ 1 - 2
src/popup/index.js

@@ -20,8 +20,7 @@ new Vue({
 Object.assign(handlers, {
   SetPopup(data, src) {
     if (store.currentTab.id !== src.tab.id) return;
-    const { menus } = data;
-    store.commands = Object.entries(menus)
+    store.commands = Object.entries(data.menus)
     .reduce((map, [id, values]) => {
       map[id] = Object.keys(values).sort();
       return map;

文件差異過大導致無法顯示
+ 269 - 274
yarn.lock


部分文件因文件數量過多而無法顯示