-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
executable file
·151 lines (118 loc) · 4.85 KB
/
background.js
File metadata and controls
executable file
·151 lines (118 loc) · 4.85 KB
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
146
147
148
149
150
151
/*
This extension is specifically for use with Loggly. Clicking this extension's button will execute the "ViewSurroundingEvents"
functionality, but keep all filters except the last one added.
*/
/*
OnMessage from contentScript
- sends message here once the surEvnts tab has opened, and user has submitted customizations
- the message contains the search text and filters (hosts, apps, etc) (which may have been altered)
- get url of current tab (chrome.tab...)
- alter url by adding the search text and filters
*/
// chrome.browserAction.onClicked.addListener(function(tab) {
// chrome.tabs.executeScript({
// code: 'document.body.style.backgroundColor="red"'
// });
// });
//"https://piper.loggly.com/search#terms=syslog.host%3A%22tv2%22&from=2016-06-26T17%3A04%3A21.745Z&until=2016-06-26T17%3A14%3A07.745Z&source_group="
// "https://piper.loggly.com/search#terms=syslog.host%3A%22tv2%22&from=2016-06-26T17%3A04%3A21.745Z&until=2016-06-26T17%3A14%3A07.745Z&source_group="
// var filter = {urls: ["https://piper.loggly.com/*"]};
// chrome.webRequest.onBeforeSendHeaders.addListener(
// function(details){
// console.info("WebRequest onBeforeSendHeaders");
// console.info(details.url);
// for (var i = 0; i < details.requestHeaders.length; ++i) {
// console.info(details.requestHeaders[i].name + ": " + details.requestHeaders[i].value);
// if (details.requestHeaders[i].name === 'User-Agent') {
// details.requestHeaders.splice(i, 1);
// break;
// }
// }
// return {requestHeaders: details.requestHeaders};
// }, filter, ["blocking", "requestHeaders"]);
// chrome.webRequest.onCompleted.addListener(
// function(details){
// console.debug("WebRequest onCompleted");
// //printDetails(details, /((tab)+|(event)+|(surround)+|(view)+)/);
// printDetails(details, /source_group/);
// }, filter);
// function printDetails(details, matchStringInUrl) {
// console.debug("--------");
// if (details["url"].match(matchStringInUrl)) {
// console.info("URL-match" + ":" + details["url"]);
// console.info(details["url"].match(matchStringInUrl));
// }
// }
// chrome.webNavigation.onCompleted.addListener(
// function(details){
// console.info("WebNavigation onCompleted");
// }, filter);
/* Runs when extension first starts ***************************/
//chrome.windows.onFocusChanged.addListener(updateMenu);
// chrome.contextMenus.create({
// "title": "Print Data",
// "contexts": ["browser_action"],
// "onclick": printAllData
// });
/* Utility Functions ***************************/
function getCurrentTab(callback) {
var queryInfo = {
active: true,
currentWindow: true
};
chrome.tabs.query(queryInfo, function(tabs) {
var tab = tabs[0];
callback(tab);
});
}
/* **************** */
/* Menu functionality ***************************/
// Return function for onClick event in right-click menu
// function tabOpenerFunction (windowId) {
// // How did this become a string.
// if (typeof windowId == "string") windowId = parseInt(windowId);
// return function (onClickEvent) {
// var url = onClickEvent.linkUrl;
// chrome.tabs.create({
// 'windowId': windowId,
// 'url': url,
// 'active': false
// });
// };
// }
// // Populate right-click menu
// function updateMenu (focusChangedEvent) {
// chrome.contextMenus.removeAll(function () {
// console.log("update menu");
// console.log(Object.keys(windowIdByLabel));
// console.log(Object.keys(windowLabelById));
// console.log(windowIdByLabel);
// console.log(windowLabelById);
// var windowNames = getAllWindowNames();
// if (windowNames.length > 0) {
// var mainMenu = chrome.contextMenus.create({
// title: 'Open specific window',
// contexts: ['browser_action']
// });
// for (var i = 0; i < windowNames.length; i++) {
// chrome.contextMenus.create({
// title: windowNames[i],
// contexts: ['browser_action'],
// onclick: tabOpenerFunction(i),
// parentId: mainMenu
// });
// }
// }
// });
// }
/* **************** */
/* DEV ONLY - Print all data to console ***************************/
function printAllData() {
// console.log("Window-Url Pairs---------");
// console.log(cachedWindowUrlPairs);
// //console.log("Urls for current window ---------");
// console.log("WindowID-label");
// console.log(windowLabelById);
// console.log("WindowLabel-id");
// console.log(windowIdByLabel);
}