1
0
Fork 0

Switch extension to MV2

main
Ambrose Chua 2021-10-17 00:20:40 +08:00
parent 03ac203786
commit e31f5b5f41
4 changed files with 14 additions and 24 deletions

View File

@ -1,9 +1,3 @@
async function getCurrentTab() {
let queryOptions = { active: true, currentWindow: true };
let [tab] = await chrome.tabs.query(queryOptions);
return tab;
}
chrome.runtime.onInstalled.addListener(() => { chrome.runtime.onInstalled.addListener(() => {
chrome.contextMenus.create({ chrome.contextMenus.create({
title: 'Make Gather fullscreen', title: 'Make Gather fullscreen',
@ -15,14 +9,11 @@ chrome.runtime.onInstalled.addListener(() => {
chrome.contextMenus.onClicked.addListener(async (data) => { chrome.contextMenus.onClicked.addListener(async (data) => {
if (data.menuItemId === 'make-fullscreen') { if (data.menuItemId === 'make-fullscreen') {
const tab = await getCurrentTab(); chrome.tabs.insertCSS({
await chrome.scripting.insertCSS({ file: 'inject.css',
target: { tabId: tab.id },
files: ['inject.css'],
}); });
await chrome.scripting.executeScript({ chrome.tabs.executeScript({
target: { tabId: tab.id }, file: 'inject.js',
files: ['inject.js'],
}); });
} }
}); });

View File

@ -1,12 +1,10 @@
body { .GameComponent-container > :nth-child(1) > :nth-child(1) {
transform: translate(-72px, 0); display: none !important;
width: calc(100vw + 72px);
} }
/* Additional */ /* Additional */
.GameCanvasContainer-settings { .GameCanvasContainer-settings {
display: none; display: none;
} }
.GameVideo-self-video-container { .GameVideo-self-video-container {
display: none; display: none !important;
} }

View File

@ -2,7 +2,9 @@
const script = document.createElement('script'); const script = document.createElement('script');
script.innerHTML = ` script.innerHTML = `
window.innerWidth = window.outerWidth + 72; window.innerWidth = window.outerWidth + 72;
window.innerHeight = window.outerHeight; window.addEventListener('resize', () => {
window.innerWidth = window.outerWidth + 72;
});
`; `;
document.head.appendChild(script); document.head.appendChild(script);

View File

@ -2,11 +2,10 @@
"name": "Gather Fullscreen", "name": "Gather Fullscreen",
"description": "Click to show Gather in fullscreen", "description": "Click to show Gather in fullscreen",
"version": "1.0", "version": "1.0",
"permissions": ["contextMenus", "scripting"], "permissions": ["contextMenus", "activeTab", "https://gather.town/app/*"],
"host_permissions": ["https://gather.town/app/*"],
"background": { "background": {
"type": "module", "scripts": ["background.js"],
"service_worker": "background.js" "persistent": false
}, },
"manifest_version": 3 "manifest_version": 2
} }