Test Script Cross Domain POST

All tests are outputed to developer javascript console (try F12 hotkey)

  1. // ==UserScript==
  2. // @name Test Script Cross Domain POST
  3. // @description All tests are outputed to developer javascript console (try F12 hotkey)
  4. // @namespace Cross_Domain_POST
  5. // @include http://www.reddit.com/r/GreaseMonkey/comments/2wb05u/troubleshooting_dev_tampermonkey_gm/
  6. // @version 2.01
  7. // @grant GM_xmlhttpRequest
  8. // @noframes
  9. // @run-at document-end
  10. // ==/UserScript==
  11. (function () {
  12. "use strict";
  13.  
  14. if (document.usr_trig !== undefined) {
  15. return;
  16. }
  17.  
  18. document.usr_trig = true;
  19.  
  20. console.log('start');
  21.  
  22. function init() {
  23. /* YOUR CODE BEGIN */
  24. console.log('init begin');
  25. GM_xmlhttpRequest({
  26. method: "POST",
  27. url: "http://www.w3schools.com/php/welcome.php",
  28. headers: {
  29. "User-Agent": "Mozilla/5.0",
  30. "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
  31. },
  32. data: "name=test&email=test",
  33. onload: function (response) {
  34. console.log ("========== response start ============");
  35. console.log([
  36. response.status,
  37. response.statusText,
  38. response.readyState,
  39. response.responseHeaders,
  40. response.responseText,
  41. response.finalUrl
  42. ].join("\n"));
  43.  
  44. console.log ("========== response end ============");
  45. console.log ("finish");
  46. }
  47. });
  48.  
  49. console.log('init end');
  50. /* YOUR CODE END */
  51. }
  52.  
  53. document.addEventListener("DOMContentLoaded", init);
  54.  
  55. }());