bookmarklet passing data to form

This commit is contained in:
smilerz
2021-03-25 17:48:32 -05:00
parent 09d2e9f831
commit f80c44bca3
8 changed files with 434 additions and 28 deletions

View File

@@ -18,19 +18,28 @@
}
function initBookmarklet() {
(window.bookmarkletTandoor = function() {
r = confirm('Click OK to import recipe automatically, click Cancel to import the recipe manually.');
if (r) {
auto=true
} else {
auto=false
}
var recipe = document.documentElement.innerHTML
var form = document.createElement("form");
var windowName = "ImportRecipe"
form.setAttribute("method", "post");
form.setAttribute("action", localStorage.getItem('importURL'));
form.setAttribute("target",'importRecipe');
var params = { 'recipe' : recipe,'url': window.location};
var newIframe = document.createElement('iframe');
newIframe.width = '200';newIframe.height = '200';
newIframe.src = localStorage.getItem('importURL');
document.body.appendChild(newIframe);
for (var i in params) {
if (params.hasOwnProperty(i)) {
var input = document.createElement('input');
input.type = 'hidden';
input.name = i;
input.value = params[i];
form.appendChild(input);
}
}
document.body.appendChild(form);
window.open('', windowName);
form.target = windowName;
form.submit();
document.body.removeChild(form);
}
)();
}