I made a Hangman game in python- let's do it in javascript now. I want to make it portable instead of embedded in a website, so let's make it as a userscript.
system
maine paythan main ek jallaad khel banaaya- chalo ab javascript main karte hai.main ise ek website main ambeded ke bajaay portable bananaa chahta hum, isliye aaie ise ek upyogkarta ke rup main banaate hai.
user
yahaan ek udhaaharan he ki aap javascript upyogkartaaon main hanthri ke khel ko kaise lagu kar sakate hai.

window.addeventListener ('lod', fnction () {
    mukhya()
});

kaary mukhya () {
// shabd pradarshan tatv
var WordDisplay = document.createelement ("div");
WordDisplay.id = "shabd";
WordDisplay.style.fontsize = "36px";
WordDisplay.style.marginbottom = "20px";
WordDisplay.innerhtml = "play hangen!";
document.body.AppendChild (WordDisplay);

// anumaanit tatv kaa anumaan lagaataa he
var guessesdisplay = document.createelement ("div");
kespesDisplay.id = "anumaan";
kespesDisplay.style.fontsize = "24px";
kespesdisplay.style.marginbottom = "20px";
guessDisplay.innerhtml = "shuru karne ke liye ek patr kaa anumaan lagaaein";
document.body.appendchild (guessesdisplay);

// letters batan container tatv
var buttonContainer = document.createelement ("div");
ButtonContainer.id = "batan";
document.body.AppendChild (ButtonContainer);

// batan ko riset karen
var ricetubton = document.createelement ("batan");
Resetbutton.innerhtml = "riset";
RESETBUTTON.STYLE.FONTSISE = "16PX";
RESETBUTTON.STYLE.PADDING = "10PX";
Resetbutton.style.margin = "5px";
RESETBUTTON.ADDEVENTLISTENER ("clic", fnction () {
resetGame ();
});
ButtonContainer.AppendChild (ResetButton);

// patr batan
for (var i = 0; i <26; i ++) {
var letters = string.fromcharcode (97 + i);
var batan = document.createelement ("batan");
button.id = patr;
button.innerhtml = patr;
button.style.fontsize = "16px";
button.style.padding = "10px";
button.style.margin = "5px";
button.addeventListener ("clic", fnction () {
handlebatanclic (this.innerhtml);
});
ButtonContainer.AppendChild (batan);

}

// siesas styles
var cssstyles = `
h1 {
paath-sanrekhan: centre;
}

#shabd {
font-aakaar: 36px;
margin-bottm: 20px;
}

#guesses {
font-aakaar: 24px;
margin-bottm: 20px;
}

#Buttons batan {
font-aakaar: 16px;
gaddi: 10px;
margin: 5px;
}
`;

// CSS shaileyon ko inject karen
var style = document.createelement ("style");
style.innerhtml = cssstyles;
document.head.appendchild (style);

// shabd shabdkosh
var shabd = ["char", "fnction", "object", "sarani", "string", "number", "bulian", "nal", "aparibhaashit", "oparator", "vidhi", "sampatti"," event "," colbach "," librari "," jecori "," riect "," node.jees "," jsan "," ajaks "," dom "," prototip "," closer "," constructor"," ES6 "];

// ek yadrichhik shabd chune
var shabd = shabd [math.floor (math.random () * shabd. length)];

// khaali sarani ko trek karne ke liye jo anumaan lagaaya gaya he
var anumaanitta = [];

// galat anumaanon ko trek karne ke liye char
var galat tareeke se = 0;

// shabd pradarshan ko apadet karen
fnction UpdateWordDisplay () {
var displaverd = "";
for (var i = 0; i <word.length; i ++) {
if (anumaanit.
DisplayWord += Word [i];
} anya {
DisplayWord += "_";// ungused patron ko ek anderscore ke saath badal diya jaataa he
}
}
WordDisplay.innerhtml = displayWord;
}

// anumaanon ko adhyatan karen pradarshan
fnction updategetuesesdisplay () {
kespesDisplay.innerhtml = "anumaan:" + galatgah;
}

// yadi anumaanit patr sarani main shabd shaamil he, to sach vaapasi, anyathaa jari rakhen
fnction checkforwin () {
for (var i = 0; i <word.length; i ++) {
if!
vivaran jhootha he;
}
}
sach lauten;
}

// yadi galat anumaan 6 yaa adhik hai, to sahi lauten
fnction checkforloss () {
galat tareeke se vaapasi karen> = 6;
}

// riset char or yuai tatv
fnction risetum () {
shabd = shabd [math.floor (math.random () * shabd. length)];// ek nayaa shabd praapt karen
anumaanit karne vaale = [];
galat tareeke se = 0;
UpdateWordDisplay ();
updateguesesdisplay ();
var buttons = document.getElementsByTagName ("batan");
for (var i = 0; i <buttons.length; i ++) {
batan [i] .disabled = false;
batan [i] .style.backgroundcolor = "";
}}


// letters batan par clic karen fnction
fnction handlebatanclic (patr) {
    var batan = document.getElementByid (patr);// batan char par clic kiye gaye patr ko asin karen
if
Tustedletters.push (patr);
if (word.includes (akshar)) {// yadi akshar shabd kaa hissaa nahin he,
galat tareeke se ++;
}
UpdateWordDisplay ();
updateguesesdisplay ();
if (checkforwin ()) {
alert ("aapane" + shabd + "shabd kaa anumaan lagaaya!");
} or agar (checkforloss ()) {
alert ("kshamaa karen, shabd" + shabd + "tha.");
}
}
     button.disabled = true;// clic kiye gaye batan ko aksham karen
button.style.backgroundcolor = "#ddddddd";
    }
}

yah code document.createelement () or appendChild () kaa upyog karke UI tatv banaata he or website kii sanrachana ke aadhaar par sanshodhit karne kii aavashyaktaa ho sakati he jahaan aap ise chalaane kaa iraadaa rakhte hai.code teen yuai tatv banaata he: ek shabd disple, jise UpdateWordsDisplay () fnction, ek anumaan pradarshan dwaara niyantrit kiya jaataa he, jo ki UpdateTateSessDisplay () fnction, or ek batan tatv container dwaara niyantrit kiya jaataa he, jo handlebatanclic () dwaara sambhala jaataa he.
assistant
<|system|>
</s>
<|user|>
maine paythan main ek jallaad khel banaaya- chalo ab javascript main karte hai.main ise ek website main ambeded ke bajaay portable bananaa chahta hum, isliye aaie ise ek upyogkarta ke rup main banaate hai.</s>
<|assistant|>
yahaan ek udhaaharan he ki aap javascript upyogkartaaon main hanthri ke khel ko kaise lagu kar sakate hai.

window.addeventListener ('lod', fnction () {
    mukhya()
});

kaary mukhya () {
// shabd pradarshan tatv
var WordDisplay = document.createelement ("div");
WordDisplay.id = "shabd";
WordDisplay.style.fontsize = "36px";
WordDisplay.style.marginbottom = "20px";
WordDisplay.innerhtml = "play hangen!";
document.body.AppendChild (WordDisplay);

// anumaanit tatv kaa anumaan lagaataa he
var guessesdisplay = document.createelement ("div");
kespesDisplay.id = "anumaan";
kespesDisplay.style.fontsize = "24px";
kespesdisplay.style.marginbottom = "20px";
guessDisplay.innerhtml = "shuru karne ke liye ek patr kaa anumaan lagaaein";
document.body.appendchild (guessesdisplay);

// letters batan container tatv
var buttonContainer = document.createelement ("div");
ButtonContainer.id = "batan";
document.body.AppendChild (ButtonContainer);

// batan ko riset karen
var ricetubton = document.createelement ("batan");
Resetbutton.innerhtml = "riset";
RESETBUTTON.STYLE.FONTSISE = "16PX";
RESETBUTTON.STYLE.PADDING = "10PX";
Resetbutton.style.margin = "5px";
RESETBUTTON.ADDEVENTLISTENER ("clic", fnction () {
resetGame ();
});
ButtonContainer.AppendChild (ResetButton);

// patr batan
for (var i = 0; i <26; i ++) {
var letters = string.fromcharcode (97 + i);
var batan = document.createelement ("batan");
button.id = patr;
button.innerhtml = patr;
button.style.fontsize = "16px";
button.style.padding = "10px";
button.style.margin = "5px";
button.addeventListener ("clic", fnction () {
handlebatanclic (this.innerhtml);
});
ButtonContainer.AppendChild (batan);

}

// siesas styles
var cssstyles = `
h1 {
paath-sanrekhan: centre;
}

#shabd {
font-aakaar: 36px;
margin-bottm: 20px;
}

#guesses {
font-aakaar: 24px;
margin-bottm: 20px;
}

#Buttons batan {
font-aakaar: 16px;
gaddi: 10px;
margin: 5px;
}
`;

// CSS shaileyon ko inject karen
var style = document.createelement ("style");
style.innerhtml = cssstyles;
document.head.appendchild (style);

// shabd shabdkosh
var shabd = ["char", "fnction", "object", "sarani", "string", "number", "bulian", "nal", "aparibhaashit", "oparator", "vidhi", "sampatti"," event "," colbach "," librari "," jecori "," riect "," node.jees "," jsan "," ajaks "," dom "," prototip "," closer "," constructor"," ES6 "];

// ek yadrichhik shabd chune
var shabd = shabd [math.floor (math.random () * shabd. length)];

// khaali sarani ko trek karne ke liye jo anumaan lagaaya gaya he
var anumaanitta = [];

// galat anumaanon ko trek karne ke liye char
var galat tareeke se = 0;

// shabd pradarshan ko apadet karen
fnction UpdateWordDisplay () {
var displaverd = "";
for (var i = 0; i <word.length; i ++) {
if (anumaanit.
DisplayWord += Word [i];
} anya {
DisplayWord += "_";// ungused patron ko ek anderscore ke saath badal diya jaataa he
}
}
WordDisplay.innerhtml = displayWord;
}

// anumaanon ko adhyatan karen pradarshan
fnction updategetuesesdisplay () {
kespesDisplay.innerhtml = "anumaan:" + galatgah;
}

// yadi anumaanit patr sarani main shabd shaamil he, to sach vaapasi, anyathaa jari rakhen
fnction checkforwin () {
for (var i = 0; i <word.length; i ++) {
if!
vivaran jhootha he;
}
}
sach lauten;
}

// yadi galat anumaan 6 yaa adhik hai, to sahi lauten
fnction checkforloss () {
galat tareeke se vaapasi karen> = 6;
}

// riset char or yuai tatv
fnction risetum () {
shabd = shabd [math.floor (math.random () * shabd. length)];// ek nayaa shabd praapt karen
anumaanit karne vaale = [];
galat tareeke se = 0;
UpdateWordDisplay ();
updateguesesdisplay ();
var buttons = document.getElementsByTagName ("batan");
for (var i = 0; i <buttons.length; i ++) {
batan [i] .disabled = false;
batan [i] .style.backgroundcolor = "";
}}


// letters batan par clic karen fnction
fnction handlebatanclic (patr) {
    var batan = document.getElementByid (patr);// batan char par clic kiye gaye patr ko asin karen
if
Tustedletters.push (patr);
if (word.includes (akshar)) {// yadi akshar shabd kaa hissaa nahin he,
galat tareeke se ++;
}
UpdateWordDisplay ();
updateguesesdisplay ();
if (checkforwin ()) {
alert ("aapane" + shabd + "shabd kaa anumaan lagaaya!");
} or agar (checkforloss ()) {
alert ("kshamaa karen, shabd" + shabd + "tha.");
}
}
     button.disabled = true;// clic kiye gaye batan ko aksham karen
button.style.backgroundcolor = "#ddddddd";
    }
}

yah code document.createelement () or appendChild () kaa upyog karke UI tatv banaata he or website kii sanrachana ke aadhaar par sanshodhit karne kii aavashyaktaa ho sakati he jahaan aap ise chalaane kaa iraadaa rakhte hai.code teen yuai tatv banaata he: ek shabd disple, jise UpdateWordsDisplay () fnction, ek anumaan pradarshan dwaara niyantrit kiya jaataa he, jo ki UpdateTateSessDisplay () fnction, or ek batan tatv container dwaara niyantrit kiya jaataa he, jo handlebatanclic () dwaara sambhala jaataa he.</s>
