From 42ed2b1268cd38a5ddf0b378be9b0257bd7ae5a4 Mon Sep 17 00:00:00 2001 From: the1812 Date: Thu, 29 Nov 2018 19:57:51 +0800 Subject: [PATCH] Refactor flatMap polyfill --- bilibili-evolved.offline.user.js | 11 ++++++----- bilibili-evolved.preview-offline.user.js | 11 ++++++----- bilibili-evolved.preview.user.js | 9 +++++---- bilibili-evolved.user.js | 9 +++++---- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/bilibili-evolved.offline.user.js b/bilibili-evolved.offline.user.js index f03eaf9a0..1004f227d 100644 --- a/bilibili-evolved.offline.user.js +++ b/bilibili-evolved.offline.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Offline) -// @version 134.90 +// @version 136.17 // @description 增强哔哩哔哩Web端体验(离线版): 修复界面瑕疵, 删除广告, 使用夜间模式浏览, 下载视频或视频封面, 以及增加对触屏设备的支持等. // @author Grant Howard, Coulomb-G // @copyright 2018, Grant Howrad (https://github.com/the1812) @@ -1053,11 +1053,11 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m .map(mapFunc) .reduce((acc, it) => acc.concat(it), []); }; - return flatMap.bind(this.styles); + return flatMap; } else { - return Array.prototype.flatMap.bind(this.styles); + return Array.prototype.flatMap; } } loadCache() @@ -1072,7 +1072,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m return settings.cache[key]; } } - download() + async download() { const key = this.key; return new Promise((resolve, reject) => @@ -1083,7 +1083,8 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m } else { - const flattenStyles = this.flatMapPolyfill()(it => typeof it === "object" ? it.key : it); + const flattenStyles = this.flatMapPolyfill() + .bind(this.styles)(it => typeof it === "object" ? it.key : it); Promise.all(this.dependencies .concat(flattenStyles.map(it => Resource.all[it])) .map(r => r.download()) diff --git a/bilibili-evolved.preview-offline.user.js b/bilibili-evolved.preview-offline.user.js index ccc990f54..750693170 100644 --- a/bilibili-evolved.preview-offline.user.js +++ b/bilibili-evolved.preview-offline.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Preview Offline) -// @version 134.90 +// @version 136.17 // @description 增强哔哩哔哩Web端体验(预览离线版): 修复界面瑕疵, 删除广告, 使用夜间模式浏览, 下载视频或视频封面, 以及增加对触屏设备的支持等. // @author Grant Howard, Coulomb-G // @copyright 2018, Grant Howrad (https://github.com/the1812) @@ -1053,11 +1053,11 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m .map(mapFunc) .reduce((acc, it) => acc.concat(it), []); }; - return flatMap.bind(this.styles); + return flatMap; } else { - return Array.prototype.flatMap.bind(this.styles); + return Array.prototype.flatMap; } } loadCache() @@ -1072,7 +1072,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m return settings.cache[key]; } } - download() + async download() { const key = this.key; return new Promise((resolve, reject) => @@ -1083,7 +1083,8 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m } else { - const flattenStyles = this.flatMapPolyfill()(it => typeof it === "object" ? it.key : it); + const flattenStyles = this.flatMapPolyfill() + .bind(this.styles)(it => typeof it === "object" ? it.key : it); Promise.all(this.dependencies .concat(flattenStyles.map(it => Resource.all[it])) .map(r => r.download()) diff --git a/bilibili-evolved.preview.user.js b/bilibili-evolved.preview.user.js index 3b5538031..0091bb2c5 100644 --- a/bilibili-evolved.preview.user.js +++ b/bilibili-evolved.preview.user.js @@ -1001,11 +1001,11 @@ .map(mapFunc) .reduce((acc, it) => acc.concat(it), []); }; - return flatMap.bind(this.styles); + return flatMap; } else { - return Array.prototype.flatMap.bind(this.styles); + return Array.prototype.flatMap; } } loadCache() @@ -1020,7 +1020,7 @@ return settings.cache[key]; } } - download() + async download() { const key = this.key; return new Promise((resolve, reject) => @@ -1031,7 +1031,8 @@ } else { - const flattenStyles = this.flatMapPolyfill()(it => typeof it === "object" ? it.key : it); + const flattenStyles = this.flatMapPolyfill() + .bind(this.styles)(it => typeof it === "object" ? it.key : it); Promise.all(this.dependencies .concat(flattenStyles.map(it => Resource.all[it])) .map(r => r.download()) diff --git a/bilibili-evolved.user.js b/bilibili-evolved.user.js index 4179453ef..413858f94 100644 --- a/bilibili-evolved.user.js +++ b/bilibili-evolved.user.js @@ -1001,11 +1001,11 @@ .map(mapFunc) .reduce((acc, it) => acc.concat(it), []); }; - return flatMap.bind(this.styles); + return flatMap; } else { - return Array.prototype.flatMap.bind(this.styles); + return Array.prototype.flatMap; } } loadCache() @@ -1020,7 +1020,7 @@ return settings.cache[key]; } } - download() + async download() { const key = this.key; return new Promise((resolve, reject) => @@ -1031,7 +1031,8 @@ } else { - const flattenStyles = this.flatMapPolyfill()(it => typeof it === "object" ? it.key : it); + const flattenStyles = this.flatMapPolyfill() + .bind(this.styles)(it => typeof it === "object" ? it.key : it); Promise.all(this.dependencies .concat(flattenStyles.map(it => Resource.all[it])) .map(r => r.download())