Skip to content

Instantly share code, notes, and snippets.

@kimikimi714
Last active January 17, 2016 11:57
Show Gist options
  • Save kimikimi714/512dc4ca3943070de7e6 to your computer and use it in GitHub Desktop.
Save kimikimi714/512dc4ca3943070de7e6 to your computer and use it in GitHub Desktop.
chrome extension test
var remind = function (detail) {
console.log(detail.url);
// chrome.notifications.create('reminder', {
// type: 'basic',
// iconUrl: 'icon-128.png',
// title: 'sent request! ' + detail.tabId,
// message: detail.url
// }, function(notificationId) {});
}
var sendRequest = function (tabId, changeInfo, tab) {
// if (changeInfo.url !== 'undefined') {
// chrome.webRequest.onSendHeaders.addListener(remind, {urls: [changeInfo.url]}, ["requestHeaders"]);
console.log(changeInfo.status + ': ' + changeInfo.url);
// }
}
// chrome.alarms.create('remindme', {delayInMinutes: 0.1});
// chrome.alarms.onAlarm.addListener(remind);
// chrome.tabs.onUpdated.addListener(sendRequest);
// chrome.webRequest.onSendHeaders.addListener(remind, {urls: ["<all_urls>"]}, ["requestHeaders"]);
var counter = 0;
chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
counter++;
console.log('tabs: ' + counter + ', ' + changeInfo.status + ': ' + changeInfo.url);
});
chrome.webRequest.onSendHeaders.addListener(function (detail) {
console.log('webRequest: ' + counter + ', ' + detail.url);
counter++;
},
{urls: ["<all_urls>"]},
["requestHeaders"]
);
{
"manifest_version": 2,
"name": "test",
"version": "0.0.1",
"browser_action": {
"default_title": "test",
"default_popup": "index.html"
},
"background": {
"scripts": [
"chrome.js"
]
},
"permissions": [
"alarms",
"notifications",
"storage",
"tabs",
"webRequest",
"<all_urls>"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment