MCPcopy Index your code
hub / github.com/MALSync/MALSync / minimalWindowAction

Function minimalWindowAction

src/background/messageHandler.ts:106–152  ·  view source on GitHub ↗
(message: minimalWindow, sender, sendResponse)

Source from the content-addressed store, hash-verified

104}
105
106function minimalWindowAction(message: minimalWindow, sender, sendResponse) {
107 api.storage.get('windowId').then(winId => {
108 if (typeof winId === 'undefined') winId = 22;
109 if (chrome.windows && chrome.windows.update && chrome.windows.create) {
110 chrome.windows.update(winId, { focused: true }, function () {
111 if (chrome.runtime.lastError) {
112 const config: any = {
113 url: chrome.runtime.getURL('window.html'),
114 type: 'popup',
115 };
116
117 if (message.width) {
118 config.width = message.width;
119 }
120 if (message.height) {
121 config.height = message.height;
122 }
123 if (message.left) {
124 config.left = message.left;
125 }
126
127 chrome.windows.create(config, function (win) {
128 api.storage.set('windowId', win!.id);
129 sendResponse();
130 });
131 } else {
132 sendResponse();
133 }
134 });
135 } else {
136 chrome.tabs.update(winId, { active: true }, function () {
137 if (chrome.runtime.lastError) {
138 const config: any = {
139 url: chrome.runtime.getURL('window.html'),
140 active: true,
141 };
142
143 chrome.tabs.create(config, function (win) {
144 api.storage.set('windowId', win!.id);
145 sendResponse();
146 });
147 }
148 });
149 }
150 });
151 return true;
152}
153
154function emitterAction(message: emitter, sender, sendResponse) {
155 chrome.runtime.sendMessage(message);

Callers 1

messageHandlerFunction · 0.85

Calls 2

getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected