Test Script Cross Domain POST

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Test Script Cross Domain POST
// @description All tests are outputed to developer javascript console (try F12 hotkey)
// @namespace   Cross_Domain_POST
// @include     http://www.reddit.com/r/GreaseMonkey/comments/2wb05u/troubleshooting_dev_tampermonkey_gm/
// @version     2.01
// @grant       GM_xmlhttpRequest
// @noframes
// @run-at      document-end
// ==/UserScript==
(function () {
    "use strict";

    if (document.usr_trig !== undefined) {
        return;
    }

    document.usr_trig = true;

    console.log('start');

    function init() {
        /* YOUR CODE BEGIN */
        console.log('init begin');
        
        GM_xmlhttpRequest({
            method: "POST",
            url: "http://www.w3schools.com/php/welcome.php",
            headers: {
                "User-Agent": "Mozilla/5.0",
                "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
            },
            data: "name=test&email=test",
            onload: function (response) {
                
                console.log ("========== response start ============");
                
                console.log([
                    response.status,
                    response.statusText,
                    response.readyState,
                    response.responseHeaders,
                    response.responseText,
                    response.finalUrl
                ].join("\n"));

                console.log ("========== response end ============");
                
                console.log ("finish");
            }
        });

        console.log('init end');
        /* YOUR CODE END */
    }

    document.addEventListener("DOMContentLoaded", init);

}());