Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
inject css, addressing issue #48
Browse files Browse the repository at this point in the history
  • Loading branch information
x0a committed May 19, 2023
1 parent 034f3ca commit 354785d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class SettingsManager {
const store = await browser.storage.sync.get(null);

if (throwOnOrigin && (!store.instance || store.instance === instance)) throw 'The changes originated from same instance or are incomplete';

const parsedStore = this.decompress(store);
const parsedSubscriptions = JSON.parse(localStorage?.getItem('subscriptions') || '[]');

Expand Down Expand Up @@ -620,6 +620,11 @@ SettingsManager.getSettings()
active: true
})
.then(() => browser.tabs.remove(sender.tab.id)))
.on('css', sender => browser.tabs.insertCSS(sender.tab.id, {
code: '#container .ad-showing > .html5-video-container { display: block !important; }',
allFrames: true,
cssOrigin: 'user'
}))
.on('mute', (sender, shouldMute: boolean) => browser.tabs.update(sender.tab.id, { muted: shouldMute }))
.on('last-ad', sender => ads.getLastAdFromTab(sender.tab.id))
.on('echo-ad', (sender, ad) => ads.echo(sender.tab.id, ad))
Expand Down
1 change: 0 additions & 1 deletion src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const MainContentAPI: ContentAPI = {
el.setAttribute('href', browser.runtime.getURL('userscript.css'));
return el;
},

sendMessage<T = any>(action: string, subaction: string, param?: any): Promise<T> {
return browser.runtime.sendMessage({ action, subaction, param })
.then((response: any) => {
Expand Down
3 changes: 2 additions & 1 deletion src/contentmain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ export const main = (api: ContentAPI) => {
.on('recent-ad', () => api.sendMessage('tab', 'last-ad'))
.on('echo-ad', ad => api.sendMessage('tab', 'echo-ad', ad))
.on('mute-tab', (shouldMute: boolean) => api.sendMessage('tab', 'mute', shouldMute || false))
.on('highlight-tab', () => api.sendMessage('tab', 'highlight'));
.on('highlight-tab', () => api.sendMessage('tab', 'highlight'))
.on('css', () => api.sendMessage('tab', 'css'));

hookReload();
hook.inject();
Expand Down
2 changes: 1 addition & 1 deletion src/userscript.css
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,4 @@ html[dark] .UBO-wl-btn.UBO-wl-poly.yt-uix-button-toggled {

.force-hide {
display: none !important;
}
}
1 change: 1 addition & 0 deletions src/userscript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,7 @@ agent
.then(response => {
log('uBO-YT', 'Initiated with the following settings', response)
agent.send('mute-tab', false) // reset
agent.send('css');
settings = new Settings(response.settings);
subscriptions = new Channels(response.subscriptions, 'subscriptions', 'cache');
AdOptions.uboIcon = response.accessURLs.ICO;
Expand Down

0 comments on commit 354785d

Please sign in to comment.