1
0
Fork 0

Initial MV3

main
Ambrose Chua 2021-10-17 00:02:59 +08:00
commit 03ac203786
5 changed files with 68 additions and 0 deletions

28
background.js Normal file
View File

@ -0,0 +1,28 @@
async function getCurrentTab() {
let queryOptions = { active: true, currentWindow: true };
let [tab] = await chrome.tabs.query(queryOptions);
return tab;
}
chrome.runtime.onInstalled.addListener(() => {
chrome.contextMenus.create({
title: 'Make Gather fullscreen',
type: 'normal',
documentUrlPatterns: ["https://gather.town/app/*"],
id: 'make-fullscreen',
});
});
chrome.contextMenus.onClicked.addListener(async (data) => {
if (data.menuItemId === 'make-fullscreen') {
const tab = await getCurrentTab();
await chrome.scripting.insertCSS({
target: { tabId: tab.id },
files: ['inject.css'],
});
await chrome.scripting.executeScript({
target: { tabId: tab.id },
files: ['inject.js'],
});
}
});

5
inject.1080p.txt Normal file
View File

@ -0,0 +1,5 @@
window.innerWidth = 1920 + 72;
window.innerHeight = 1080;
document.body.style.transform = 'translate(-72px, 0)';
document.body.style.width = `${1920 + 72}px`;

12
inject.css Normal file
View File

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

11
inject.js Normal file
View File

@ -0,0 +1,11 @@
{
const script = document.createElement('script');
script.innerHTML = `
window.innerWidth = window.outerWidth + 72;
window.innerHeight = window.outerHeight;
`;
document.head.appendChild(script);
//document.body.style.transform = 'translate(-72px, 0)';
//document.body.style.width = `${window.outerWidth + 72}px`;
}

12
manifest.json Normal file
View File

@ -0,0 +1,12 @@
{
"name": "Gather Fullscreen",
"description": "Click to show Gather in fullscreen",
"version": "1.0",
"permissions": ["contextMenus", "scripting"],
"host_permissions": ["https://gather.town/app/*"],
"background": {
"type": "module",
"service_worker": "background.js"
},
"manifest_version": 3
}