Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function update() {
Request({
url: notifUrl,
onComplete: function( response ) {
worker.port.emit( 'render', response.text );
}
// Need to add a check if the computer is connected to the internet.
// Waiting on a `onError` method.
}).get();
};
exports.loadHTML = function(url, values, callback) {
request.Request({
url: url,
content: values,
onComplete: function(response) {
// Only way to parse HTML is by loading it in a hidden iframe
// See https://developer.mozilla.org/en/Parsing_HTML_From_Chrome
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
loadHTMLText(response.text, ios.newURI(url, null, null), callback);
}
}).post();
};
exports.test_url = function(test) {
require("request").Request({
url: "http://www.mozilla.org/",
onComplete: function(response) {
test.assertEqual(response.statusText, "OK");
test.done();
}
}).get();
test.waitUntilDone(20000);
};
getExtractorOptions: function (url) {
var serverUrl = URLs.SERVER + "/query?url=" + encodeURIComponent(url);
Request({
url: serverUrl,
onComplete: (function (response) {
if (response.status != 200) {
console.log('Bad result: ' + response.status);
this.panel.port.emit("Error", "There was an error fetching " + serverUrl + ": " + response.status);
return;
}
this.extractorOptions = response.json.extractors;
if (typeof this.extractorOptions != 'object') {
console.log('Error; extractors is not a list:', response.json);
throw 'Error: extractors is not a list';
}
this.allConsumers = response.json.consumers;
console.log('Got extractor options; ' + this.extractorOptions.length + ' extractors and ' + this.allConsumers.length + ' consumers');
this.panel.port.emit("Consumers", this.allConsumers, this.extractorOptions);
if (this.consumerChosen) {
worker.port.on("loadResource", function (data) {
var url, responseHash;
url = data.param;
responseHash = data.hash;
require("request").Request({
url: url,
onComplete: function (response) {
worker.port.emit(responseHash, { response: response.text });
}
}).get();
});
function requestMagnifier(url, pid, count, myWorker) {
Request({
url: url + "/api/read/json?id=" + pid,
headers: {tryCount: count,
retryLimit: getStorage("MissingE_magnifier_retries",defaultRetries),
targetId: pid},
onComplete: function(response) {
if (response.status != 200 ||
!(/^\s*var\s+tumblr_api_read/.test(response.text))) {
var entry;
if ((entry = cache[this.headers.targetId])) {
doMagnifier(entry, this.headers.targetId, myWorker);
}
else {
if (this.headers.tryCount <= this.headers.retryLimit) {
requestMagnifier(this.url.replace(/\/api\/read\/json\?id=[0-9]*$/,''), this.headers.targetId, (this.headers.tryCount + 1), myWorker);
}
else {
function requestTimestamp(url, pid, count, myWorker) {
Request({
url: url + "/api/read/json?id=" + pid,
headers: {tryCount: count,
retryLimit: getStorage("MissingE_timestamp_retries",defaultRetries),
targetId: pid},
onComplete: function(response) {
if (response.status != 200 ||
!(/^\s*var\s+tumblr_api_read/.test(response.text))) {
var entry;
if ((entry = cache[this.headers.targetId])) {
doTimestamp(entry, this.headers.targetId, myWorker);
}
else {
if (this.headers.tryCount <= this.headers.retryLimit) {
requestTimestamp(this.url.replace(/\/api\/read\/json\?id=[0-9]*$/,''), this.headers.targetId, (this.headers.tryCount + 1), myWorker);
}
else {
gUserProfile.demographer.pickRandomBest(function suggestCat(cat) {
let toggle = false;
let req = request.Request({
url: "https://sitesuggest.mozillalabs.com/" ,
headers: { "Category": cat },
onComplete: function(response) {
if( response.status == 200 ) {
ref.setAttribute('title', response.json.title);
ref.setAttribute('href', response.json.url);
spanImage.setAttribute('style','background-image: url("' + response.json.image + '");');
spanTitle.textContent = response.json.title;
spanCatTitle.textContent = "Your interest: " + cat;
window.setInterval(function keepLoading() {
if( toggle ) {
spanCatTitle.setAttribute( "style" , "transition-property: margin-bottom; transition-duration: 1s; margin-bottom: -20px;");
toggle = false;
}
else {
spanCatTitle.setAttribute( "style" , "transition-property: margin-bottom; transition-duration: 1s; margin-bottom: 0px;");
};
if (request.method == 'POST') {
Request({
url: request.url,
onComplete: function(response) {
responseObj.response = {
responseText: response.text,
status: response.status
};
worker.postMessage(responseObj);
},
headers: request.headers,
content: request.data
}).post();
} else {
Request({
url: request.url,
onComplete: function(response) {
responseObj.response = {
responseText: response.text,
status: response.status
};
worker.postMessage(responseObj);
},
headers: request.headers,
content: request.data
}).get();
}
break;
case 'createTab':
var focus = (request.background !== true);
tabs.open({url: request.url, inBackground: !focus });