Skip to content

Instantly share code, notes, and snippets.

@mhsattarian
Created January 17, 2024 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhsattarian/ae2d16f012b53f4cd036ed7bcb67ea4b to your computer and use it in GitHub Desktop.
Save mhsattarian/ae2d16f012b53f4cd036ed7bcb67ea4b to your computer and use it in GitHub Desktop.
A simple (browser)action Chrome extension to add a rotate Instagram lives/stories
chrome.action.onClicked.addListener(function (tab) {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
var activeTab = tabs[0];
chrome.tabs.sendMessage(activeTab.id, {
message: "clicked_browser_action",
});
});
});
function doSmthing() {
var videoEl = document.querySelector("video");
videoEl.setAttribute("controls", "");
var prevRotate = 0;
if (videoEl.style.transform)
prevRotate = parseInt(videoEl.style.transform.split("(")[1].slice(0, -4));
document.body.style.cssText = `
rotate: ${prevRotate + 90}deg;
`;
}
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
if (request.message === "clicked_browser_action") {
doSmthing();
}
});
{
"manifest_version": 3,
"name": "IGLive landscape",
"description": "Make instagram live video landscape",
"version": "0.1",
"icons": { "64": "icon.png" },
"action": {
"default_icon": "icon.png",
"default_title": "Make live video landscape!"
},
"background": {
"service_worker": "background.js"
},
"content_scripts": [
{
"matches": ["https://www.instagram.com/*"],
"js": ["content.js"]
}
],
"host_permisson": ["https://www.instagram.com/*"],
"permissions": ["tabs", "webNavigation"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment