MCPcopy
hub / github.com/philc/vimium / create

Function create

background_scripts/marks.js:17–37  ·  view source on GitHub ↗
(req, sender)

Source from the content-addressed store, hash-verified

15// mark is used, whether this is the original Vimium session or a subsequent session. This affects
16// whether or not tabId can be considered valid.
17export async function create(req, sender) {
18 const items = await chrome.storage.session.get("vimiumSecret");
19 const markInfo = {
20 vimiumSecret: items.vimiumSecret,
21 markName: req.markName,
22 url: getBaseUrl(sender.tab.url),
23 tabId: sender.tab.id,
24 scrollX: req.scrollX,
25 scrollY: req.scrollY,
26 };
27
28 if ((markInfo.scrollX != null) && (markInfo.scrollY != null)) {
29 saveMark(markInfo);
30 } else {
31 // The front-end frame hasn't provided the scroll position (because it's not the top frame
32 // within its tab). We need to ask the top frame what its scroll position is.
33 chrome.tabs.sendMessage(sender.tab.id, { handler: "getScrollPosition" }, (response) => {
34 saveMark(Object.assign(markInfo, { scrollX: response.scrollX, scrollY: response.scrollY }));
35 });
36 }
37}
38
39function saveMark(markInfo) {
40 const item = {};

Callers

nothing calls this directly

Calls 3

getBaseUrlFunction · 0.85
saveMarkFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected