Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #39. Send custom HTTP header when reporting issue. #40

Merged
merged 3 commits into from
Sep 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chrome/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ function reportIssue (tab) {
});
}

chrome.contextMenus.onClicked.addListener(function (tab) { reportIssue(tab) });
chrome.browserAction.onClicked.addListener(function (tab) { reportIssue(tab) });
chrome.contextMenus.onClicked.addListener(reportIssue);
chrome.browserAction.onClicked.addListener(reportIssue);
20 changes: 17 additions & 3 deletions firefox-webext/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

var prefix = 'https://webcompat.com/?open=1&url=';
var screenshotData = '';
var reporterID = 'addon-reporter-firefox';

chrome.contextMenus.create({
id: "webcompat-contextmenu",
title: "Report site issue",
contexts: ["all"]
});


function reportIssue (tab) {
chrome.tabs.captureVisibleTab({format: 'png'}, function(res) {
screenshotData = res;
Expand All @@ -25,5 +25,19 @@ function reportIssue (tab) {
});
}

chrome.contextMenus.onClicked.addListener(function (tab) { reportIssue(tab) });
chrome.browserAction.onClicked.addListener(function (tab) { reportIssue(tab) });
chrome.contextMenus.onClicked.addListener(reportIssue);
chrome.browserAction.onClicked.addListener(reportIssue);

// Add a custom header when the user is reporting an issue.
chrome.webRequest.onBeforeSendHeaders.addListener(
function(details) {
details.requestHeaders.push({
name: 'X-Reported-With',
value: `${reporterID}`
});

return {requestHeaders: details.requestHeaders};
},
{urls: ["https://webcompat.com/?open=1&*"]},

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

['blocking', 'requestHeaders']
);
2 changes: 2 additions & 0 deletions firefox-webext/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"tabs",
"activeTab",
"contextMenus",
"webRequest",
"webRequestBlocking",
"https://webcompat.com/",
"<all_urls>"
],
Expand Down
4 changes: 2 additions & 2 deletions opera/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ function reportIssue (tab) {
});
}

chrome.contextMenus.onClicked.addListener(function (tab) { reportIssue(tab) });
chrome.browserAction.onClicked.addListener(function (tab) { reportIssue(tab) });
chrome.contextMenus.onClicked.addListener(reportIssue);
chrome.browserAction.onClicked.addListener(reportIssue);