GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ChromeLock/bg.js at main · morpheusadam/ChromeLock

Expand file tree

/

bg.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
145 lines (121 loc) · 4.1 KB
/

bg.js

Copy path

File metadata and controls

145 lines (121 loc) · 4.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//author-- eswar yaga
let activeListener;
let closedTabs = []; // Array to store closed tabs
let lastOptionsId = null;
chrome.runtime.onInstalled.addListener(async function(details){
await chrome.tabs.create({
url: "set-password.html"
});
});
chrome.runtime.onStartup.addListener(async function(){
chrome.storage.local.get(['key'], (result) => {
//console.log('Value retrieved:', result.key);
if(result.key) {
closeAllTabs();
chrome.tabs.create({ url: chrome.runtime.getURL("enter-password.html") }, (tab) => {
// The 'tab' parameter contains the newly created tab's details
//console.log("New tab ID:", tab.id);
let currentWindowId = tab.id;
lastOptionsId = tab.id;
activeListener = createOnTabActivated(currentWindowId);
chrome.tabs.onActivated.addListener(activeListener);
chrome.tabs.onUpdated.addListener(onTabUpdated);
});
} else {
chrome.tabs.create({ url: chrome.runtime.getURL("set-password.html") });
}
});
});
function onTabUpdated(tabId, changeInfo, tab) {
if (tabId === lastOptionsId) {
if (changeInfo.url && changeInfo.url !== chrome.runtime.getURL("enter-password.html")) {
//console.log(`Closing enter-password.html tab because URL changed: ${changeInfo.url}`);
chrome.tabs.remove(tabId); // Close the options tab
}
}
}
function createOnTabActivated(currentWindowId) {
return function(activeInfo) {
//console.log('Tab activated:', activeInfo);
//console.log('Additional arguments:', currentWindowId);
chrome.tabs.get(activeInfo.tabId, (tabs) => {
if (tabs.id !== currentWindowId) {
// Close the previous window if it's different from the new active tab's window
chrome.windows.getCurrent({}, function(window) {
chrome.windows.remove(window.id);
});
}
});
};
}
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.action === "removeListener") {
if (activeListener) {
reopenClosedTabs();
chrome.tabs.onActivated.removeListener(activeListener);
chrome.tabs.onUpdated.removeListener(onTabUpdated);
//console.log('Listener removed');
activeListener = null; // Clear the reference after removing
}
sendResponse({ success: true });
}
});
function closeA(){
chrome.windows.getAll({}, function(window) {
for(var i=0;i<window.length;i++){
chrome.windows.remove(window[i].id);}
});
}
function closeAllTabs() {
chrome.tabs.query({}, (tabs) => {
closedTabs = tabs
.filter(tab => tab.url !== chrome.runtime.getURL("enter-password.html"))
.filter(tab => tab.url !== chrome.runtime.getURL("set-password.html"))
.map(tab => ({
url: tab.url,
windowId: tab.windowId,
index: tab.index,
}));
// Close all tabs
tabs.forEach(tab => {
chrome.tabs.remove(tab.id);
});
//console.log('All tabs closed and stored:', closedTabs);
});
}
function reopenClosedTabs() {
if (closedTabs.length === 0) {
chrome.tabs.query({ url: chrome.runtime.getURL("enter-password.html") }, (tabs) => {
tabs.forEach((tab) => {
chrome.tabs.remove(tab.id, () => {
//console.log('Closed set-password.html tab with ID:', tab.id);
});
});
});
// No tabs to reopen, open about:blank
chrome.tabs.create({ url: "about:blank" }, (newTab) => {
//console.log('Opened about:blank:', newTab.id);
});
} else {
closedTabs.forEach(tab => {
chrome.tabs.create({
url: tab.url,
windowId: tab.windowId,
index: tab.index
}, (newTab) => {
//console.log('Reopened tab:', newTab.id);
});
});
chrome.tabs.query({ url: chrome.runtime.getURL("enter-password.html") }, (tabs) => {
tabs.forEach((tab) => {
chrome.tabs.remove(tab.id, () => {
//console.log('Closed set-password.html tab with ID:', tab.id);
});
});
});
}
closedTabs= null;
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.