Extension Purpose and Intention
The "Open Link on Second Monitor" Chrome extension is designed to enhance user productivity by allowing links to be opened directly on a second monitor. This is particularly useful for users with multi-monitor setups who want to manage their screen real estate more efficiently.
Code Functionality
-
Context Menu Creation:
- The extension adds a context menu item labeled "Open Link on Second Monitor" that appears when right-clicking on a link.
chrome.contextMenus.create({
id: "openLinkSecondMonitor",
title: "Open Link on Second Monitor",
contexts: ["link"]
});
-
Event Listener for Menu Click:
- Listens for clicks on the context menu item and retrieves the URL of the clicked link.
chrome.contextMenus.onClicked.addListener((info, tab) => {
if (info.menuItemId === "openLinkSecondMonitor") {
const url = info.linkUrl;
-
Window Creation and Positioning:
- Opens the link in a new window and attempts to position it on the second monitor by accessing display information.
chrome.windows.create({
url: url,
focused: true
}, (newWindow) => {
chrome.system.display.getInfo((displays) => {
if (displays.length > 1) {
const secondMonitor = displays[1];
chrome.windows.update(newWindow.id, {
left: secondMonitor.bounds.left,
top: secondMonitor.bounds.top,
width: secondMonitor.bounds.width,
height: secondMonitor.bounds.height,
state: "normal"
});
}
});
});
-
Script Injection:
- Injects a script (
fullscreen.js) into the new tab to potentially modify its behavior, such as making it fullscreen.
chrome.scripting.executeScript({
target: { tabId: tabId },
files: ['fullscreen.js']
});
Network and API Calls
- Chrome API Usage:
- Utilizes
chrome.contextMenus, chrome.windows, chrome.system.display, and chrome.scripting APIs.
- No External Network Communication:
- The code does not make any network requests or communicate with external servers.
Filesystem Activity
- Script Injection:
- The extension injects a local script (
fullscreen.js) into the tab, but there is no indication of filesystem manipulation or data exfiltration.
Potential Malicious Indicators
- Script Injection:
- While script injection is a common technique for modifying web pages, it can be used maliciously. However, in this context, it appears to be used for enhancing the user experience by adjusting the display settings.
Conclusion
The extension appears to be designed for legitimate purposes, enhancing user experience by managing window placement on multiple monitors. There are no strong indicators of malicious behavior, such as unauthorized data access, external network communication, or obfuscation techniques.