Pet*_*uza 32 google-chrome bookmarks http
您可以使用 GET 请求存储书签,如下所示:
http://url.com/service?variable=value
Run Code Online (Sandbox Code Playgroud)
您可以在 Chrome 中以某种方式存储 POST 请求吗?也许用插件?或者也许在 Firefox 中?
这个想法是我将它存储在书签中并快速启动它,而不必每次都填写表格。
Den*_*nis 19
这个想法是我将它存储在书签中并快速启动它,而不必每次都填写表格。
为此,以下 HTML 页面将完成。它应该适用于大多数浏览器。
<html>
<head>
<title>getToPost</title>
<script>
function getToPost()
{
var form = document.getElementsByTagName('form')[0];
form.style.visibility = 'hidden';
form.action = document.location.hash.substr(1);
var search = decodeURIComponent(document.location.search);
search = search.substr(1).split('&');
for(var i = 0, j = search.length, input; i < j; i++)
{
input = document.createElement('input');
search[i] = search[i].split('=');
input.name = search[i][0];
input.value = search[i][1];
form.appendChild(input);
}
form.submit();
}
</script>
</head>
<body onload="getToPost()">
<form method="POST"></form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
将其另存为C:\getToPost,您可以将以下 URL 加入书签:
file:///C:/getToPost?name1=value1&name2=value2#http://url.com/service
Run Code Online (Sandbox Code Playgroud)
您将能够按字面意思在名称或值中使用大多数字符。像往常一样编码以下内容:
# -> %23
% -> %25
& -> %26
= -> %3D
Run Code Online (Sandbox Code Playgroud)
您可以创建一个使用 JavaScript 在单击时发送 POST 请求的书签。
以下代码通过将表单附加到当前活动页面然后提交它foo=bar来发送带有有效负载的 POST 请求https://example.com:
post('https://example.com', { foo: 'bar' })
function post (url, formData) {
const h = (tag, props) => Object.assign(document.createElement(tag), props)
const form = h('form', { action: url, method: 'post', hidden: true })
for (const [name, value] of Object.entries(formData)) {
form.appendChild(h('input', { name, value }))
}
document.body.appendChild(form)
form.submit()
}
Run Code Online (Sandbox Code Playgroud)
要将其用作书签,只需将以下内容设置为书签的目标(适当替换 URL 和表单数据):
javascript:post('https://example.com',{foo:'bar'});function post(a,b){const c=(e,f)=>Object.assign(document.createElement(e),f),d=c('form',{action:a,method:'post',hidden:true});for(const[e,f]of Object.entries(b))d.appendChild(c('input',{name:e,value:f}));document.body.appendChild(d),d.submit()}
Run Code Online (Sandbox Code Playgroud)
其简单地javascript:接着从上方缩小的形式的代码。
小智 6
如果要寻找不需要依赖附加组件或外部文件的跨浏览器解决方案,可以使用以下语法将 Javascript 直接放置在书签中以实现此目的:
javascript:(function(){ <Your Javascript code goes here> })();
Run Code Online (Sandbox Code Playgroud)
从 Denis 的回答中借用一些代码来说明:
javascript:(function()
{
var form = document.getElementsByTagName('form')[0];
form.style.visibility = 'hidden';
form.method = 'post';
form.action = 'https://your.urlgoes.here/build?delay=0sec';
var search = 'name=ENVIRONMENT&value=production&name=DEPLOYTYPE&value=Incremental&name=BRANCH&value=master&statusCode=303&redirectTo=.&json={"parameter": [{"name": "ENVIRONMENT", "value": "production"}, {"name": "DEPLOYTYPE", "value": "Incremental"}, {"name": "BRANCH", "value": "master"}], "statusCode": "303", "redirectTo": "."}&Submit=Build';
search = search.substr(1).split('&');
for(var i = 0, j = search.length, input; i < j; i++)
{
input = document.createElement('input');
search[i] = search[i].split('=');
input.name = search[i][0];
input.value = search[i][1];
form.appendChild(input);
}
form.submit();}
)();
Run Code Online (Sandbox Code Playgroud)
缺点是所有这些都必须在一行上,因为书签是单行,所以使用它可能会有点费神。这在书签本身中:
javascript:(function(){ var form = document.getElementsByTagName('form')[0]; form.style.visibility = 'hidden'; form.method = 'post'; form.action = 'https://your.urlgoes.here/build?delay=0sec'; var search = 'name=ENVIRONMENT&value=production&name=DEPLOYTYPE&value=Incremental&name=BRANCH&value=master&statusCode=303&redirectTo=.&json={"parameter": [{"name": "ENVIRONMENT", "value": "production"}, {"name": "DEPLOYTYPE", "value": "Incremental"}, {"name": "BRANCH", "value": "master"}], "statusCode": "303", "redirectTo": "."}&Submit=Build'; search = search.substr(1).split('&'); for(var i = 0, j = search.length, input; i < j; i++) { input = document.createElement('input'); search[i] = search[i].split('='); input.name = search[i][0]; input.value = search[i][1]; form.appendChild(input); } form.submit(); })();
Run Code Online (Sandbox Code Playgroud)
许多空格可用于轻松转换为更具可读性的内容并返回到单行。在上面的例子中," " 可以在 Notepad++ 之类的东西中用 \r\n 替换,以将其转换回多行。然后将其转换回单行查找并替换 \r\n 替换为“”将其转换回单行。这使它稍微不那么弯曲......
| 归档时间: |
|
| 查看次数: |
16851 次 |
| 最近记录: |