2021-01-01 14:27:58 +00:00
|
|
|
/* global API */// msg.js
|
2020-10-03 12:05:40 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// onCommitted may fire twice
|
|
|
|
// Note, we're checking against a literal `1`, not just `if (truthy)`,
|
|
|
|
// because <html id="INJECTED"> is exposed per HTML spec as a global variable and `window.INJECTED`.
|
|
|
|
|
|
|
|
if (window.INJECTED_GREASYFORK !== 1) {
|
|
|
|
window.INJECTED_GREASYFORK = 1;
|
|
|
|
addEventListener('message', async function onMessage(e) {
|
|
|
|
if (e.origin === location.origin &&
|
|
|
|
e.data &&
|
|
|
|
e.data.name &&
|
|
|
|
e.data.type === 'style-version-query') {
|
|
|
|
removeEventListener('message', onMessage);
|
2021-01-01 14:27:58 +00:00
|
|
|
const style = await API.usercss.find(e.data) || {};
|
2020-10-03 12:05:40 +00:00
|
|
|
const {version} = style.usercssData || {};
|
|
|
|
postMessage({type: 'style-version', version}, '*');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|