Discussões » Criação de Solicitações
Script doesn't work anymore, who can fix it?
Oh hey, that's me.
Could you try this way. Instead of relying on the click events, it tries to make all the changes directly. I didn't submit the form, so I don't know whether I got everything.
function switchDisplay(){
var ptabs = document.querySelectorAll('#syi-price-tabs a');
if (ptabs.length == 0){
window.setTimeout(switchDisplay, 500);
return;
}
if (ptabs[1].className.indexOf("selected") > -1) return;
// Switch selected class
ptabs[0].className = ptabs[0].className.replace("selected", "");
ptabs[1].className += " selected";
// Set hidden input
var frm = document.getElementById("syi-form");
frm.elements["price.option"].value = "priceType";
// Change visibility of controls
document.getElementById("syi-price").style.display = "none";
document.getElementById("syi-price-type").style.display = "block";
// Set selected for "Bieden" option in the select control
var ptv = frm.elements["price.typeValue"];
for (var i=0; i<ptv.options.length; i++){
if (ptv.options[i].textContent == "Bieden"){
console.log("Found Bieden");
ptv.options[i].selected = true;
break;
}
}
}
if (window.self == window.top) window.setTimeout(switchDisplay, 1000);
It works perfect, also with submit, Manny thanks Jefferson!
Is it also possible to set "toon op kaart" not filled by default?
Is it also possible to set "toon op kaart" not filled by default?
Took me a while to find that, since I'm not logged in, it's hidden.
function switchDisplay(){
var ptabs = document.querySelectorAll('#syi-price-tabs a');
if (ptabs.length == 0){
window.setTimeout(switchDisplay, 500);
return;
}
if (ptabs[1].className.indexOf("selected") > -1) return;
// Switch selected class
ptabs[0].className = ptabs[0].className.replace("selected", "");
ptabs[1].className += " selected";
// Set hidden input
var frm = document.getElementById("syi-form");
frm.elements["price.option"].value = "priceType";
// Change visibility of controls
document.getElementById("syi-price").style.display = "none";
document.getElementById("syi-price-type").style.display = "block";
// Set selected for "Bieden" option in the select control
var ptv = frm.elements["price.typeValue"];
for (var i=0; i<ptv.options.length; i++){
if (ptv.options[i].textContent == "Bieden"){
console.log("Found Bieden");
ptv.options[i].selected = true;
break;
}
}
// Do not show location on map
var chkMap = document.getElementById("show-on-map");
if (chkMap){
chkMap.checked = false;
if (chkMap.hasAttribute("checked")) chkMap.removeAttribute("checked");
}
}
if (window.self == window.top) window.setTimeout(switchDisplay, 1000);
The show on map is ok but now I see that after the submit the price value choice is set to "gratis" instead of "bieden" it needs more work I am afraid
What?? Try switching the order because I'm not seeing that:
function switchDisplay(){
// Select pricing
var ptabs = document.querySelectorAll('#syi-price-tabs a');
if (ptabs.length == 0){
window.setTimeout(switchDisplay, 500);
return;
}
if (ptabs[1].className.indexOf("selected") > -1) return;
// Do not show location on map
var chkMap = document.getElementById("show-on-map");
if (chkMap){
chkMap.checked = false;
if (chkMap.hasAttribute("checked")) chkMap.removeAttribute("checked");
}
// Switch selected class
ptabs[0].className = ptabs[0].className.replace("selected", "");
ptabs[1].className += " selected";
// Set hidden input
var frm = document.getElementById("syi-form");
frm.elements["price.option"].value = "priceType";
// Change visibility of controls
document.getElementById("syi-price").style.display = "none";
document.getElementById("syi-price-type").style.display = "block";
// Set selected for "Bieden" option in the select control
var ptv = frm.elements["price.typeValue"];
for (var i=0; i<ptv.options.length; i++){
if (ptv.options[i].textContent == "Bieden"){
console.log("Found Bieden");
ptv.options[i].selected = true;
break;
}
}
}
if (window.self == window.top) window.setTimeout(switchDisplay, 1000);
Maybe a good idea to undisable the price type drop-down in case you need to adjust it manually...
function switchDisplay(){
// Select pricing
var ptabs = document.querySelectorAll('#syi-price-tabs a');
if (ptabs.length == 0){
window.setTimeout(switchDisplay, 500);
return;
}
if (ptabs[1].className.indexOf("selected") > -1) return;
// Do not show location on map
var chkMap = document.getElementById("show-on-map");
if (chkMap){
chkMap.checked = false;
if (chkMap.hasAttribute("checked")) chkMap.removeAttribute("checked");
}
// Switch selected class
ptabs[0].className = ptabs[0].className.replace("selected", "");
ptabs[1].className += " selected";
// Set hidden input
var frm = document.getElementById("syi-form");
frm.elements["price.option"].value = "priceType";
// Change visibility of controls
document.getElementById("syi-price").style.display = "none";
document.getElementById("syi-price-type").style.display = "block";
// Set selected for "Bieden" option in the select control
var ptv = frm.elements["price.typeValue"];
for (var i=0; i<ptv.options.length; i++){
if (ptv.options[i].textContent == "Bieden"){
console.log("Found Bieden");
ptv.options[i].selected = true;
break;
}
}
if (ptv.hasAttribute("disabled")) ptv.removeAttribute("disabled");
}
if (window.self == window.top) window.setTimeout(switchDisplay, 1000);
Jefferson, You make it look like it's magic, it works flawless
Great. Hopefully it will be a while before they change that page again.
Script doesn't work anymore, who can fix it?
In 2012 mr Jefferson has created a (greasemonkey) script below for the website marktplaats.nl. It seems that marktplaats changed something because I can't get the script working any more. With firebug and common sence I can't see what is wrong but I guess it is something small. So I wanted to upload the script but the website userscripts is closed http://userscripts-mirror.org/topics/119213.html
Is it possible to have a look at it?
To test the script use https://www.marktplaats.nl/syi/plaatsAdvertentie.html
Type word:
boeken
click:vind rubriek
, click on the created link below Half way down in the new page the pricetypeprijs
appears I need default Kies ander prijstype > biedenJefferson Scher wrote on my e-mail:
But when I try to fix this, it breaks the part of the form just below that...