lin*_*le5 2 javascript json greasemonkey
我正在玩GreaseMonkey沙箱,尝试制作一个脚本来将加载的页面转发到另一台服务器以通过POST处理。这是脚本:
// ==UserScript==
// @name Mirror Page
// @namespace mailto:linkhyrule5@gmail.com
// @description POSTs page to dynamic page mirror
// @include http://*
// @include https://*
// @version 1
// @grant GM_xmlhttpRequest
// ==/UserScript==
var ihtml = document.body.innerHTML;
GM_xmlhttpRequest({
method: 'POST',
url: 'http://localhost:5723/index.php',
data: "PageContents=" + encodeURIcomponent(ihtml) + "\nURL=" + encodeURIcomponent(document.URL),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
Run Code Online (Sandbox Code Playgroud)
无论如何,encodeURIcomponent is not defined即使它是一个全局函数,我也应该得到它,并且应该可以在JavaScript所在的任何地方使用。我以为我误会了什么?
您忘记了大写字母C ...就像Camel-Case:
var ihtml = document.body.innerHTML;
GM_xmlhttpRequest({
method: 'POST',
url: 'http://localhost:5723/index.php',
data: "PageContents=" + encodeURIComponent(ihtml) + "\nURL=" + encodeURIComponent(document.URL),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4339 次 |
| 最近记录: |