Created
August 10, 2023 19:09
-
-
Save mansouryaacoubi/7c82868d1f9ffa2282d2ad120e4f9aaa to your computer and use it in GitHub Desktop.
FDDB Register Weight Data from already existing data like Excel or CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use CSRFTOKEN for your current session | |
// Copy this whole code into the developer console of your FDDB Browser Tab | |
const CSRFTOKEN = "871432"; | |
async function createWeight(date, weight, bfp) { | |
var day = date.getDate().toString(); | |
var month = (date.getMonth()+1).toString(); | |
var year = date.getFullYear().toString(); | |
var myHeaders = new Headers(); | |
myHeaders.append("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"); | |
myHeaders.append("Accept-Language", "es-ES,es;q=0.9,de;q=0.8"); | |
myHeaders.append("Cache-Control", "max-age=0"); | |
myHeaders.append("Connection", "keep-alive"); | |
myHeaders.append("Content-Type", "application/x-www-form-urlencoded"); | |
myHeaders.append("Cookie", "PHPSESSID=m3sfkpah3dmldsnscatndt7pap; _pk_id.1.125c=83b22f8a0199b7a9.1691653059.; CookieConsent={stamp:%27ZVBuxpBwes7tvkd7TV5O4oFDd+C1ZHUCZvC79Xf8DRIukES+Ug60eg==%27%2Cnecessary:true%2Cpreferences:true%2Cstatistics:true%2Cmarketing:true%2Cmethod:%27explicit%27%2Cver:1%2Cutc:1691653061633%2Cregion:%27de%27}; fddb=6208309%2CS4YNDAAN6AKSR8QK; _pk_ses.1.125c=1; PHPSESSID=hrhkfq52v0uvgldqojtdgm7mco; fddb=6208309%2CS4YNDAAN6AKSR8QK"); | |
myHeaders.append("Origin", "https://fddb.info"); | |
myHeaders.append("Referer", "https://fddb.info/db/i18n/mydata/?lang=en&action=new"); | |
myHeaders.append("Sec-Fetch-Dest", "document"); | |
myHeaders.append("Sec-Fetch-Mode", "navigate"); | |
myHeaders.append("Sec-Fetch-Site", "same-origin"); | |
myHeaders.append("Sec-Fetch-User", "?1"); | |
myHeaders.append("Upgrade-Insecure-Requests", "1"); | |
myHeaders.append("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"); | |
myHeaders.append("sec-ch-ua", "\"Not/A)Brand\";v=\"99\", \"Google Chrome\";v=\"115\", \"Chromium\";v=\"115\""); | |
myHeaders.append("sec-ch-ua-mobile", "?0"); | |
myHeaders.append("sec-ch-ua-platform", "\"Windows\""); | |
var urlencoded = new URLSearchParams(); | |
urlencoded.append("csrftoken", CSRFTOKEN); | |
urlencoded.append("uh_date_day", day); | |
urlencoded.append("uh_date_month", month); | |
urlencoded.append("uh_date_year", year); | |
urlencoded.append("uh_weight", weight); | |
urlencoded.append("uh_bodyfat_percent", bfp); | |
urlencoded.append("uh_bodyfat_percent_checkbox", "on"); | |
urlencoded.append("uh_bodywater_percent", ""); | |
urlencoded.append("uh_bodywater_percent_checkbox", "on"); | |
urlencoded.append("uh_waist_cm", ""); | |
urlencoded.append("uh_waist_cm_checkbox", "on"); | |
urlencoded.append("uh_hip_cm", ""); | |
urlencoded.append("uh_hip_cm_checkbox", "on"); | |
var requestOptions = { | |
method: 'POST', | |
headers: myHeaders, | |
body: urlencoded, | |
redirect: 'follow' | |
}; | |
await fetch("https://fddb.info/db/i18n/mydata/?lang=en&action=adduh", requestOptions); | |
} | |
const dataArray = [{date: "2023-5-5", weight: 114.7, bfp: 0.38}, {date: "2023-5-6", weight: 114.5, bfp: 0.38}, {date: "2023-5-7", weight: 114.3, bfp: 0.38}, {date: "2023-5-8", weight: 114, bfp: 0.38}, {date: "2023-5-9", weight: 113.8, bfp: 0.38}, {date: "2023-5-10", weight: 113.5, bfp: 0.38}, {date: "2023-5-11", weight: 112.2, bfp: 0.38}, {date: "2023-5-12", weight: 111.5, bfp: 0.37}, {date: "2023-5-13", weight: 111.4, bfp: 0.37}, {date: "2023-5-14", weight: 111.8, bfp: 0.37}, {date: "2023-5-15", weight: 111.1, bfp: 0.37}, {date: "2023-5-16", weight: 111.1, bfp: 0.37}, {date: "2023-5-17", weight: 111.9, bfp: 0.37}, {date: "2023-5-18", weight: 112.4, bfp: 0.38}, {date: "2023-5-19", weight: 110.4, bfp: 0.36}, {date: "2023-5-20", weight: 109.3, bfp: 0.35}, {date: "2023-5-21", weight: 108.7, bfp: 0.35}, {date: "2023-5-22", weight: 108, bfp: 0.35}, {date: "2023-5-23", weight: 106.7, bfp: 0.34}, {date: "2023-5-24", weight: 106.4, bfp: 0.34}, {date: "2023-5-25", weight: 105.7, bfp: 0.33}, {date: "2023-5-26", weight: 105.5, bfp: 0.33}, {date: "2023-5-27", weight: 104.7, bfp: 0.34}, {date: "2023-5-28", weight: 106.5, bfp: 0.33}, {date: "2023-5-29", weight: 104.5, bfp: 0.33}, {date: "2023-5-30", weight: 105.1, bfp: 0.34}, {date: "2023-5-31", weight: 105, bfp: 0.33}, {date: "2023-6-1", weight: 105, bfp: 0.34}, {date: "2023-6-2", weight: 104.7, bfp: 0.33}, {date: "2023-6-3", weight: 104.7, bfp: 0.34}, {date: "2023-6-4", weight: 104.3, bfp: 0.33}, {date: "2023-6-5", weight: 104.3, bfp: 0.33}, {date: "2023-6-6", weight: 103.7, bfp: 0.32}, {date: "2023-6-7", weight: 103.5, bfp: 0.31}, {date: "2023-6-8", weight: 103.5, bfp: 0.32}, {date: "2023-6-9", weight: 102.8, bfp: 0.32}, {date: "2023-6-10", weight: 102.8, bfp: 0.30}, {date: "2023-6-11", weight: 102.2, bfp: 0.31}, {date: "2023-6-12", weight: 102.1, bfp: 0.31}, {date: "2023-6-13", weight: 102.1, bfp: 0.31}, {date: "2023-6-14", weight: 101.9, bfp: 0.31}, {date: "2023-6-15", weight: 101.6, bfp: 0.31}, {date: "2023-6-16", weight: 101.6, bfp: 0.31}, {date: "2023-6-17", weight: 101.3, bfp: 0.31}, {date: "2023-6-18", weight: 100.7, bfp: 0.29}, {date: "2023-6-19", weight: 100.8, bfp: 0.31}, {date: "2023-6-20", weight: 100.3, bfp: 0.31}, {date: "2023-6-21", weight: 100.3, bfp: 0.31}, {date: "2023-6-22", weight: 99.6, bfp: 0.31}, {date: "2023-6-23", weight: 100, bfp: 0.31}, {date: "2023-6-24", weight: 98.5, bfp: 0.31}, {date: "2023-6-25", weight: 97.8, bfp: 0.32}, {date: "2023-6-26", weight: 97.8, bfp: 0.31}, {date: "2023-6-27", weight: 98.1, bfp: 0.31}, {date: "2023-6-28", weight: 98.4, bfp: 0.34}, {date: "2023-6-29", weight: 97.7, bfp: 0.38}, {date: "2023-6-30", weight: 97.1, bfp: 0.36}, {date: "2023-7-1", weight: 96.2, bfp: 0.37}, {date: "2023-7-2", weight: 96, bfp: 0.36}, {date: "2023-7-3", weight: 96, bfp: 0.36}, {date: "2023-7-4", weight: 96.3, bfp: 0.33}, {date: "2023-7-5", weight: 96.4, bfp: 0.35}, {date: "2023-7-6", weight: 96.2, bfp: 0.35}, {date: "2023-7-7", weight: 96.15, bfp: 0.35}, {date: "2023-7-8", weight: 96.1, bfp: 0.35}, {date: "2023-7-9", weight: 95.7, bfp: 0.35}, {date: "2023-7-10", weight: 95.15, bfp: 0.33}, {date: "2023-7-11", weight: 95.25, bfp: 0.31}, {date: "2023-7-12", weight: 95.3, bfp: 0.34}, {date: "2023-7-13", weight: 94.85, bfp: 0.34}, {date: "2023-7-14", weight: 94.65, bfp: 0.34}, {date: "2023-7-15", weight: 94.85, bfp: 0.33}, {date: "2023-7-16", weight: 94.7, bfp: 0.35}, {date: "2023-7-17", weight: 94.45, bfp: 0.35}, {date: "2023-7-18", weight: 94.05, bfp: 0.32}, {date: "2023-7-19", weight: 93.7, bfp: 0.31}, {date: "2023-7-20", weight: 93.5, bfp: 0.32}, {date: "2023-7-21", weight: 93.75, bfp: 0.33}, {date: "2023-7-22", weight: 93.05, bfp: 0.32}, {date: "2023-7-23", weight: 93.05, bfp: 0.34}, {date: "2023-7-24", weight: 93.55, bfp: 0.32}, {date: "2023-7-25", weight: 92.65, bfp: 0.35}, {date: "2023-7-26", weight: 92.8, bfp: 0.31}, {date: "2023-7-27", weight: 92.15, bfp: 0.32}, {date: "2023-7-28", weight: 91.6, bfp: 0.29}, {date: "2023-7-29", weight: 91.3, bfp: 0.31}, {date: "2023-7-30", weight: 91.25, bfp: 0.30}, {date: "2023-7-31", weight: 91.35, bfp: 0.31}, {date: "2023-8-1", weight: 91, bfp: 0.32}, {date: "2023-8-2", weight: 91.25, bfp: 0.31}, {date: "2023-8-3", weight: 90.7, bfp: 0.32}, {date: "2023-8-4", weight: 90.75, bfp: 0.33}, {date: "2023-8-5", weight: 90.2, bfp: 0.33}, {date: "2023-8-6", weight: 90.75, bfp: 0.32}, {date: "2023-8-7", weight: 90.75, bfp: 0.32}, {date: "2023-8-8", weight: 89.9, bfp: 0.31}, {date: "2023-8-9", weight: 89.95, bfp: 0.32}, {date: "2023-8-10", weight: 89.6, bfp: 0.33}]; | |
dataArray.forEach(async (item) => { | |
console.log("Logging weight:", item.weight); | |
await createWeight(new Date(item.date), item.weight, item.bfp); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment