Skip to content

Instantly share code, notes, and snippets.

@earthchie
Last active October 1, 2024 15:48
Show Gist options
  • Select an option

  • Save earthchie/f11250b898fcc187bd3de65f13cac1ba to your computer and use it in GitHub Desktop.

Select an option

Save earthchie/f11250b898fcc187bd3de65f13cac1ba to your computer and use it in GitHub Desktop.
ระบบช่วยกรอกข้อมูล จองทะเบียนรถ ที่ https://reserve.dlt.go.th/reserve/s.php (อ่านรายละเอียดที่คอมเมนต์ด้านล่าง)
DLT_applyFields({
id: '1122334455667',
prefix: 'นาย', // ต้องสะกดให้เหมือนตัวเลือกใน dropdown เป้ะๆ
name: 'ธนารัตน์',
lname: 'นักจองทะเบียน',
phone: '0812345678',
brand: 'LAMBORGHINI', // ต้องสะกดให้เหมือนตัวเลือกใน dropdown เป้ะๆ
cassis: 'MR1234567890',
number: '999' // แนะนำให้แก้โค้ดส่วนนี้ ปรับให้อ่านค่าจาก localStorage จะได้ไม่ต้องรันเลขเองด้วยมือทุกครั้ง
});
function DLT_applyFields(data) {
isbody = 999; // bypass validation
const fields = document.querySelectorAll('input,select')
let f = {
number: document.querySelector('#number')
};
let n = [18,19,20,21,22,23,24];
for(i = 18; i <= 24; i++){
// prefix, name, lastname
if(fields[i].id === 'prefixZQ'){
f.prefix = fields[i];
f.name = fields[i+1];
f.lname = fields[i+2];
let index = n.indexOf(i);
if (index !== -1) {
n.splice(index, 3);
}
}
// brand
if(fields[i].tagName === 'SELECT' && fields[i].id !== 'prefixZQ'){
f.brand = fields[i];
let index = n.indexOf(i);
if (index !== -1) {
n.splice(index, 1);
}
}
// phone number
if(fields[i].onkeypress != null && fields[i].onkeypress.toString() == 'function onkeypress(event) {\ncheck_number()\n}'){
f.phone = fields[i];
let index = n.indexOf(i);
if (index !== -1) {
n.splice(index, 1);
}
}
// cassis number
if(fields[i].onkeypress != null && fields[i].onkeypress.toString() == 'function onkeypress(event) {\ncheck_number1()\n}'){
f.cassis = fields[i];
let index = n.indexOf(i);
if (index !== -1) {
n.splice(index, 1);
}
}
}
console.log(n, fields)
f.id = fields[n.shift()]; // id card
//apply data if provided
Object.keys(data).forEach(i=>{
f[i].value = data[i];
})
return f; // return all fields in case you need it
}
@githubhub9
Copy link
Copy Markdown

githubhub9 commented Apr 12, 2023

มีตัวฉบับสามารถใช้งานได้ให้ลองไหมครับ

Code ที่ให้มาใช้ยังไงครับ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment