我正在播放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所在的任何地方使用。我想我是误会什么了?
发布于 2016-03-20 23:51:49
你忘了资本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' }
});https://stackoverflow.com/questions/36121072
复制相似问题