import
This commit is contained in:
31
inject/fallback.js
Normal file
31
inject/fallback.js
Normal file
@@ -0,0 +1,31 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
if (document.documentElement instanceof HTMLHtmlElement &&
|
||||
matchMedia('(prefers-color-scheme: dark)').matches &&
|
||||
!document.querySelector('.darkreader--fallback')) {
|
||||
const css = 'html, body, body :not(iframe):not(div[style^="position:absolute;top:0;left:-"]) { background-color: #181a1b !important; border-color: #776e62 !important; color: #e8e6e3 !important; } html, body { opacity: 1 !important; transition: none !important; }';
|
||||
const fallback = document.createElement('style');
|
||||
fallback.classList.add('darkreader');
|
||||
fallback.classList.add('darkreader--fallback');
|
||||
fallback.media = 'screen';
|
||||
fallback.textContent = css;
|
||||
if (document.head) {
|
||||
document.head.append(fallback);
|
||||
}
|
||||
else {
|
||||
const root = document.documentElement;
|
||||
root.append(fallback);
|
||||
const observer = new MutationObserver(() => {
|
||||
if (document.head) {
|
||||
observer.disconnect();
|
||||
if (fallback.isConnected) {
|
||||
document.head.append(fallback);
|
||||
}
|
||||
}
|
||||
});
|
||||
observer.observe(root, { childList: true });
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
5124
inject/index.js
Normal file
5124
inject/index.js
Normal file
File diff suppressed because it is too large
Load Diff
33
inject/sub-success-handler.js
Normal file
33
inject/sub-success-handler.js
Normal file
@@ -0,0 +1,33 @@
|
||||
// Listen for subscription status updates from the webpage
|
||||
window.addEventListener(
|
||||
'message',
|
||||
function (event) {
|
||||
// Validate message structure and origin
|
||||
if (!event.data || typeof event.data !== 'object') return
|
||||
|
||||
const { type, text } = event.data
|
||||
|
||||
// Verify all required fields are present and valid
|
||||
if (
|
||||
type === 'FROM_PAGE' &&
|
||||
text?.type === 'subscription_status' &&
|
||||
text?.extensionId === chrome.runtime.id &&
|
||||
typeof text?.status === 'string'
|
||||
) {
|
||||
// Log the validated message
|
||||
console.log('Subscription status update received:', text.status)
|
||||
|
||||
chrome.storage.sync.set(
|
||||
{ dm_subscription_status: text.status.toLowerCase() },
|
||||
() => {
|
||||
console.log('Subscription status updated:', text.status)
|
||||
}
|
||||
)
|
||||
|
||||
if (text.status.toLowerCase() === 'active') {
|
||||
chrome.storage.sync.remove('dm_clicks_count', () => {})
|
||||
}
|
||||
}
|
||||
},
|
||||
false
|
||||
)
|
||||
Reference in New Issue
Block a user