mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-06 05:29:02 +00:00
add update notifier
This commit is contained in:
parent
d1875ffc90
commit
b5043508d9
@ -126,7 +126,8 @@ try:
|
|||||||
f' ...linking to {os.path.join(".", "resources", "user.css")}')
|
f' ...linking to {os.path.join(".", "resources", "user.css")}')
|
||||||
with open(os.path.join(__dirname__, 'resources', 'preload.js'), 'r', encoding='UTF-8') as insert:
|
with open(os.path.join(__dirname__, 'resources', 'preload.js'), 'r', encoding='UTF-8') as insert:
|
||||||
append.write(insert.read().replace(
|
append.write(insert.read().replace(
|
||||||
'☃☃☃resources☃☃☃', os.path.join(enhancer_folder, 'resources').replace('\\', '/')))
|
'☃☃☃resources☃☃☃', os.path.join(enhancer_folder, 'resources').replace('\\', '/'))
|
||||||
|
.replace('☃☃☃version☃☃☃', enhancer_version))
|
||||||
else:
|
else:
|
||||||
print(
|
print(
|
||||||
f' * {os.path.join(filepath, "app","renderer","preload.js")} was not found: step skipped.')
|
f' * {os.path.join(filepath, "app","renderer","preload.js")} was not found: step skipped.')
|
||||||
|
@ -167,9 +167,40 @@ require('electron').remote.getGlobal('setTimeout')(() => {
|
|||||||
el.outerHTML = `<span>${el.getAttribute('alt')}</span>`;
|
el.outerHTML = `<span>${el.getAttribute('alt')}</span>`;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
observer.observe(document, { childList: true, subtree: true });
|
observer.observe(document, {
|
||||||
|
childList: true,
|
||||||
|
subtree: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* update checker */
|
||||||
|
fetch(
|
||||||
|
`https://api.github.com/repos/dragonwocky/notion-enhancer/releases/latest`
|
||||||
|
)
|
||||||
|
.then((res) => res.json())
|
||||||
|
.then((res) => {
|
||||||
|
const local_version = '☃☃☃version☃☃☃'.split('~')[0],
|
||||||
|
repo_version = res.tag_name.slice(1);
|
||||||
|
// compare func from https://github.com/substack/semver-compare
|
||||||
|
if (
|
||||||
|
local_version != repo_version &&
|
||||||
|
[local_version, repo_version].sort((a, b) => {
|
||||||
|
var pa = a.split('.');
|
||||||
|
var pb = b.split('.');
|
||||||
|
for (var i = 0; i < 3; i++) {
|
||||||
|
var na = Number(pa[i]);
|
||||||
|
var nb = Number(pb[i]);
|
||||||
|
if (na > nb) return 1;
|
||||||
|
if (nb > na) return -1;
|
||||||
|
if (!isNaN(na) && isNaN(nb)) return 1;
|
||||||
|
if (isNaN(na) && !isNaN(nb)) return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
})[0] == local_version
|
||||||
|
)
|
||||||
|
alert('notion-enhancer update available!');
|
||||||
|
});
|
||||||
|
|
||||||
/* hotkey: reload window */
|
/* hotkey: reload window */
|
||||||
document.defaultView.addEventListener(
|
document.defaultView.addEventListener(
|
||||||
'keyup',
|
'keyup',
|
||||||
|
Loading…
Reference in New Issue
Block a user