@@ -916,15 +916,16 @@ api.rmrf = function() {
916
916
/******************************************************************************/
917
917
918
918
// Asset updater area.
919
-
var updaterStatus,
919
+
const updaterAssetDelayDefault = 120000;
920
+
const updaterUpdated = [];
921
+
const updaterFetched = new Set();
922
+
923
+
let updaterStatus,
920
924
updaterTimer,
921
-
updaterAssetDelayDefault = 120000,
922
925
updaterAssetDelay = updaterAssetDelayDefault,
923
-
updaterUpdated = [],
924
-
updaterFetched = new Set(),
925
926
noRemoteResources;
926
927
927
-
var updateFirst = function() {
928
+
const updateFirst = function() {
928
929
// https://github.com/gorhill/uBlock/commit/126110c9a0a0630cd556f5cb215422296a961029
929
930
// Firefox extension reviewers do not want uBO/webext to fetch its own
930
931
// scriptlets/resources asset from the project's own repo (github.com).
@@ -939,31 +940,33 @@ var updateFirst = function() {
939
940
}
940
941
updaterStatus = 'updating';
941
942
updaterFetched.clear();
942
-
updaterUpdated = [];
943
+
updaterUpdated.length = 0;
943
944
fireNotification('before-assets-updated');
944
945
updateNext();
945
946
};
946
947
947
-
var updateNext = function() {
948
-
var assetDict, cacheDict;
948
+
const updateNext = function() {
949
+
let assetDict, cacheDict;
949
950
950
951
// This will remove a cached asset when it's no longer in use.
951
-
var garbageCollectOne = function(assetKey) {
952
-
var cacheEntry = cacheDict[assetKey];
952
+
const garbageCollectOne = function(assetKey) {
953
+
const cacheEntry = cacheDict[assetKey];
953
954
if ( cacheEntry && cacheEntry.readTime < assetCacheRegistryStartTime ) {
954
955
assetCacheRemove(assetKey);
955
956
}
956
957
};
957
958
958
-
var findOne = function() {
959
-
var now = Date.now(),
960
-
assetEntry, cacheEntry;
961
-
for ( var assetKey in assetDict ) {
962
-
assetEntry = assetDict[assetKey];
959
+
const findOne = function() {
960
+
const now = Date.now();
961
+
for ( const assetKey in assetDict ) {
962
+
const assetEntry = assetDict[assetKey];
963
963
if ( assetEntry.hasRemoteURL !== true ) { continue; }
964
964
if ( updaterFetched.has(assetKey) ) { continue; }
965
-
cacheEntry = cacheDict[assetKey];
966
-
if ( cacheEntry && (cacheEntry.writeTime + assetEntry.updateAfter * 86400000) > now ) {
965
+
const cacheEntry = cacheDict[assetKey];
966
+
if (
967
+
cacheEntry &&
968
+
(cacheEntry.writeTime + assetEntry.updateAfter * 86400000) > now
969
+
) {
967
970
continue;
968
971
}
969
972
// Update of user scripts/resources forbidden?
@@ -982,7 +985,7 @@ var updateNext = function() {
982
985
}
983
986
};
984
987
985
-
var updatedOne = function(details) {
988
+
const updatedOne = function(details) {
986
989
if ( details.content !== '' ) {
987
990
updaterUpdated.push(details.assetKey);
988
991
if ( details.assetKey === 'assets.json' ) {
@@ -998,8 +1001,8 @@ var updateNext = function() {
998
1001
}
999
1002
};
1000
1003
1001
-
var updateOne = function() {
1002
-
var assetKey = findOne();
1004
+
const updateOne = function() {
1005
+
const assetKey = findOne();
1003
1006
if ( assetKey === undefined ) {
1004
1007
return updateDone();
1005
1008
}
@@ -1020,20 +1023,20 @@ var updateNext = function() {
1020
1023
});
1021
1024
};
1022
1025
1023
-
var updateDone = function() {
1024
-
var assetKeys = updaterUpdated.slice(0);
1026
+
const updateDone = function() {
1027
+
const assetKeys = updaterUpdated.slice(0);
1025
1028
updaterFetched.clear();
1026
-
updaterUpdated = [];
1029
+
updaterUpdated.length = 0;
1027
1030
updaterStatus = undefined;
1028
1031
updaterAssetDelay = updaterAssetDelayDefault;
1029
1032
fireNotification('after-assets-updated', { assetKeys: assetKeys });
1030
1033
};
1031
1034
1032
1035
api.updateStart = function(details) {
1033
-
var oldUpdateDelay = updaterAssetDelay,
1034
-
newUpdateDelay = typeof details.delay === 'number' ?
1035
-
details.delay :
1036
-
updaterAssetDelayDefault;
1036
+
const oldUpdateDelay = updaterAssetDelay;
1037
+
const newUpdateDelay = typeof details.delay === 'number' ?
1038
+
details.delay :
1039
+
updaterAssetDelayDefault;
1037
1040
updaterAssetDelay = Math.min(oldUpdateDelay, newUpdateDelay);
1038
1041
if ( updaterStatus !== undefined ) {
1039
1042
if ( newUpdateDelay < oldUpdateDelay ) {
@@ -1055,6 +1058,11 @@ api.updateStop = function() {
1055
1058
}
1056
1059
};
1057
1060
1061
+
api.isUpdating = function() {
1062
+
return updaterStatus === 'updating' &&
1063
+
updaterAssetDelay <= µBlock.hiddenSettings.manualUpdateAssetFetchPeriod;
1064
+
};
1065
+
1058
1066
/******************************************************************************/
1059
1067
1060
1068
return api;
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4