未定义 EncodeURI 组件
EncodeURIcomponent is not defined
我正在玩 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' }
});
不知何故,我得到了 encodeURIcomponent is not defined
,即使它是一个全局函数并且应该在 JavaScript 所在的任何地方可用。我想我误解了什么?
你忘了大写字母 C... 就像驼峰式一样:
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' }
});
我正在玩 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' }
});
不知何故,我得到了 encodeURIcomponent is not defined
,即使它是一个全局函数并且应该在 JavaScript 所在的任何地方可用。我想我误解了什么?
你忘了大写字母 C... 就像驼峰式一样:
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' }
});