Skip to content

Instantly share code, notes, and snippets.

@nmaier
Created June 8, 2011 18:48
Show Gist options
  • Save nmaier/1015051 to your computer and use it in GitHub Desktop.
Save nmaier/1015051 to your computer and use it in GitHub Desktop.
test ignoreRedirect and redirectionLimit
// ==UserScript==
// @id test-ignore
// @name test-ignore
// @namespace tn123.org
// @include https://tn123.org/
// ==/UserScript==
GM_xmlhttpRequest({
method: "GET",
url: "https://tn123.org/somewhere",
ignoreRedirect: true,
onload: function(response) {
GM_log("ignoreRedirect: " + (response.finalUrl == "https://tn123.org/somewhere" ? "PASS" : "FAIL"));
}
});
GM_xmlhttpRequest({
method: "GET",
url: "https://tn123.org/somewhere",
onload: function(response) {
GM_log("redirect: " + (response.finalUrl == "http://www.iana.org/domains/example/" ? "PASS" : "FAIL"));
}
});
GM_xmlhttpRequest({
method: "GET",
url: "https://tn123.org/somewhere",
redirectionLimit: 0,
onload: function(response) {
GM_log("redirectionLimit: 0; FAIL");
},
onerror: function(response) {
GM_log("redirectionLimit: 0; PASS");
}
});
GM_xmlhttpRequest({
method: "GET",
url: "https://tn123.org/somewhere",
failOnRedirect: true,
onload: function(response) {
GM_log("failOnRedirect; FAIL");
},
onerror: function(response) {
GM_log("failOnRedirect; PASS");
}
});
GM_xmlhttpRequest({
method: "GET",
url: "https://tn123.org/somewhere",
redirectionLimit: 1,
onload: function(response) {
GM_log("redirectionLimit: 1; FAIL");
},
onerror: function(response) {
GM_log("redirectionLimit: 1; PASS");
}
});
GM_xmlhttpRequest({
method: "GET",
url: "https://tn123.org/somewhere",
redirectionLimit: 10,
onload: function(response) {
GM_log("rediectonLimit: 10; PASS");
},
onerror: function(response) {
GM_log("rediectonLimit: 10; FAIL");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment