Merge branch 'master' of https://github.com/openstyles/stylus into dev-refactor
This commit is contained in:
commit
a76ec7c311
|
@ -253,6 +253,7 @@ const styleManager = (() => {
|
||||||
if (style.id == null) {
|
if (style.id == null) {
|
||||||
delete style.id;
|
delete style.id;
|
||||||
}
|
}
|
||||||
|
fixUsoMd5Issue(style);
|
||||||
return db.exec('put', style)
|
return db.exec('put', style)
|
||||||
.then(event => {
|
.then(event => {
|
||||||
if (style.id == null) {
|
if (style.id == null) {
|
||||||
|
@ -380,6 +381,7 @@ const styleManager = (() => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const style of styleList) {
|
for (const style of styleList) {
|
||||||
|
fixUsoMd5Issue(style);
|
||||||
styles.set(style.id, {
|
styles.set(style.id, {
|
||||||
appliesTo: new Set(),
|
appliesTo: new Set(),
|
||||||
data: style
|
data: style
|
||||||
|
@ -479,4 +481,12 @@ const styleManager = (() => {
|
||||||
function getUrlNoHash(url) {
|
function getUrlNoHash(url) {
|
||||||
return url.split('#')[0];
|
return url.split('#')[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The md5Url provided by USO includes a duplicate "update" subdomain (see #523),
|
||||||
|
// This fixes any already installed styles containing this error
|
||||||
|
function fixUsoMd5Issue(style) {
|
||||||
|
if (style && style.md5Url && style.md5Url.includes('update.update.userstyles')) {
|
||||||
|
style.md5Url = style.md5Url.replace('update.update.userstyles', 'update.userstyles');
|
||||||
|
}
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -159,7 +159,7 @@ API_METHODS.styleViaAPI = !CHROME && (() => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const tabFrames = cache.get(tabId);
|
const tabFrames = cache.get(tabId);
|
||||||
if (frameId in tabFrames) {
|
if (tabFrames && frameId in tabFrames) {
|
||||||
delete tabFrames[frameId];
|
delete tabFrames[frameId];
|
||||||
if (isEmpty(tabFrames)) {
|
if (isEmpty(tabFrames)) {
|
||||||
onTabRemoved(tabId);
|
onTabRemoved(tabId);
|
||||||
|
|
|
@ -218,6 +218,14 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// USO providing md5Url as "https://update.update.userstyles.org/#####.md5"
|
||||||
|
// instead of "https://update.userstyles.org/#####.md5"
|
||||||
|
function tryFixMd5(style) {
|
||||||
|
if (style && style.md5Url && style.md5Url.includes('update.update')) {
|
||||||
|
style.md5Url = style.md5Url.replace('update.update', 'update');
|
||||||
|
}
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
function getStyleJson() {
|
function getStyleJson() {
|
||||||
return getResource(getStyleURL(), {responseType: 'json'})
|
return getResource(getStyleURL(), {responseType: 'json'})
|
||||||
|
@ -236,6 +244,7 @@
|
||||||
return style;
|
return style;
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
.then(tryFixMd5)
|
||||||
.catch(() => null);
|
.catch(() => null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user