Skip to content

Commit

Permalink
rename main folder and add new POC for tabs (#2427)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuyHarwood authored Jan 31, 2023
1 parent a651b00 commit 439eb22
Show file tree
Hide file tree
Showing 89 changed files with 40 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions design/spikes/browser-tab-id/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Tab API POC</title>
</head>
<body>
<h1>Tab API</h1>
<script src="index.js"></script>
</body>
</html>
27 changes: 27 additions & 0 deletions design/spikes/browser-tab-id/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
window.addEventListener('load', (event) => {
console.log(`page is loaded. tab id is ${getTabId1()}`)
console.dir(document.tabs)
})

function getTabId2() {
return browser.tabs[0].id
}

function getTabId1() {
const sessionStorageKey = "TAB_ID_KEY"
const idFromStorage = sessionStorage.getItem(sessionStorageKey)
if (idFromStorage) {
return idFromStorage
} else {
const id = uuidv4()
sessionStorage.setItem(sessionStorageKey, id)
return id
}
}

function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
)
}

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 439eb22

Please sign in to comment.