Skip to content

Commit 8189a19

Browse files
committed
meta props + fix Notify
cached full urls in meta
1 parent 499aab4 commit 8189a19

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

userscript/fa-blacklist-latest.user.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ var meta = {
2323
LOCALES_HREF: 'webext/_locales/index.json',
2424
STYLES_HREF: 'userscript/styles.css'
2525
};
26+
meta.ICON_URL = (new URL(meta.ICON32_HREF, meta.ROOT)).href;
27+
meta.LOCALES_URL = (new URL(meta.LOCALES_HREF, meta.ROOT)).href;
28+
meta.STYLES_URL = (new URL(meta.STYLES_HREF, meta.ROOT)).href;
2629

2730
// Storage (temp placeholder for testing purposes)
2831
if (typeof GM === 'undefined') {
@@ -1166,15 +1169,13 @@ var i18n = {
11661169
_updateLocales: function (locales) {
11671170
locales = locales || {};
11681171
console.log('Fetching new locales dictionary');
1169-
var localesURL = (new URL(meta.LOCALES_HREF, meta.ROOT)).href;
1170-
console.log(localesURL);
1171-
return fetch(localesURL)
1172+
return fetch(meta.LOCALES_URL)
11721173
.then(convertToJSON)
11731174
.then(function (index) {
11741175
console.log('Locales index found:', index);
11751176
// fetch each locales file
11761177
return Promise.all(Object.keys(index).map(function (key) {
1177-
return fetch(new URL(index[key], localesURL))
1178+
return fetch(new URL(index[key], meta.LOCALES_URL))
11781179
.then(convertToJSON)
11791180
.then(function (locale) {
11801181
console.log('Locale found:', key);
@@ -3346,7 +3347,7 @@ var App = {
33463347
createMainWindow: function () {
33473348
App.$mainWindow = $Window({
33483349
title: i18n.get('extensionNameShort') + ' ' + meta.VERSION,
3349-
icon: (new URL(meta.ICON32_HREF, meta.ROOT)).href,
3350+
icon: meta.ICON_URL,
33503351
body: $TabControl({
33513352
'page': {
33523353
'tab': html('span', {'data-i18n': 'pageContentsTitle'}),
@@ -3373,11 +3374,10 @@ var App = {
33733374
return App.$mainWindow;
33743375
},
33753376
_reloadStylesheet: function () {
3376-
var stylesheetURL = (new URL(meta.STYLES_HREF, meta.ROOT)).href;
3377-
console.log('Fetching stylesheet', stylesheetURL);
3378-
return fetch(stylesheetURL)
3377+
return fetch(meta.STYLES_URL)
33793378
.then(function (x) {return x.text()})
33803379
.then(function (stylesheet) {
3380+
console.log('Fetched new stylesheet');
33813381
App.$stylesheet.innerHTML = stylesheet;
33823382
return GM.setValue('bl_stylesheet', JSON.stringify({
33833383
_version: meta.VERSION,
@@ -3437,14 +3437,14 @@ var App = {
34373437

34383438
var resultsText = '';
34393439
if (users.length) {
3440-
resultsText += i18n.get('users') + ' (' + users.length + '):\n';
3440+
resultsText += users.length + ' ' + i18n.get('users') + ':\n';
34413441
resultsText += users.map(function (user) {
34423442
return user + ' (' + getFiltersByTags(Users[user]).join(', ') + ')';
34433443
}).join('; ');
34443444
resultsText += '\n\n';
34453445
}
34463446
if (submissions.length) {
3447-
resultsText += i18n.get('submissions') + ' (' + submissions.length + '):\n';
3447+
resultsText += submissions.length + ' ' + i18n.get('submissions') + ':\n';
34483448
resultsText += submissions.map(function (sub) {
34493449
return '#' + sub + ' (' + getFiltersByTags(Submissions[sub]).join(', ') + ')';
34503450
}).join('; ');
@@ -3453,7 +3453,7 @@ var App = {
34533453
Notify(
34543454
i18n.get('extensionNameShort') + ' - ' + i18n.get('mainScanResults'),
34553455
resultsText,
3456-
ICON_URL
3456+
meta.ICON_URL
34573457
);
34583458
}
34593459
}

0 commit comments

Comments
 (0)