Skip to content

Commit

Permalink
feat: User Agent Support
Browse files Browse the repository at this point in the history
  • Loading branch information
RossWang committed Jan 19, 2018
1 parent 7bacdea commit bd335a7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions App/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,17 @@ function getFileSize(d){
return fileSize;
}

function getRequestHeaders(id) {
function getRequestHeaders(id, ua) {
// create header
var id1;
var requestHeaders = [];
var getheader = ['Referer', 'Cookie', 'Cookie2', 'Authorization'];
for (var i = 0; i < 4; i++) {
if (ua){
var getheader = ['Referer', 'Cookie', 'Cookie2', 'Authorization', 'User-Agent'];
}
else {
var getheader = ['Referer', 'Cookie', 'Cookie2', 'Authorization'];
}
for (var i = 0; i < getheader.length; i++) {
id1 = request[id].requestHeaders.findIndex(x => x.name === getheader[i]);
if (id1 >= 0) {
requestHeaders[i] = request[id].requestHeaders[id1].name + ": " +
Expand All @@ -312,7 +317,11 @@ async function prepareDownload(d) {
var id = request.findIndex(x => x.requestId === d.requestId);
if (id >= 0) {
// create header
details.requestHeaders = getRequestHeaders(id);
//details.requestHeaders = getRequestHeaders(id);
var get = browser.storage.local.get(config.command.guess);
await get.then(item => {
details.requestHeaders = getRequestHeaders(id, item.ua);
});
// delete request item
request.splice(id, 1);
}
Expand Down

0 comments on commit bd335a7

Please sign in to comment.