how to deobfuscate an obfuscated javascript code

i want to decode this obfuscated javascript cod, it cannot be done through any means like online deobfuscators in all types in base64 deobfuscator it gives some binary values in this
format->
~éܶ*’ÿLwí¯xæzíº*Þ¶êçÿLu×W”ûíõê·îËb¢ôÇ~<vö«SÛ,k”5<7;5$¹Ó,S<b56=ZVW8ÚVW+xò]«<2xËÖÉάö¿L¿@àõKoÏ{ÍH/3jL-+<#”
ÌÐÖ
¦µ¦(¶¦gg1ÀÛ<ìºà¶PÖÉÝ�ÚÏ

I WANT TO DEOBFUSCATE THE FOLLOWING CODE:
THIS IS THE CODE:
<b:tag name=’script’ type=’text/javascript’>
//<![CDATA[
function _0x37a945(n,r,t,u,i){return _0x111c(i- -316,r)}function _0x348d(){var n=[“lMf2yxrHCI1PBwfNzs1JB250ywLUzxiGAw1N”,”pc9WpJWVzgL2pJWVyt48l2rPDJ4″,”CMvWBgfJzq”,”z2v0yNv0Dg9U”,”tvz3vNm”,”kgXLzNqTC2LKzwjHCIK”,”zNDWCwq”,”mtaYotqZnZzHA2zzsuu”,”C2HVDW”,”lMndANrPDc1HDxrOB3iGlMf1DgHVCI1KzxnJCMLWDgLVBIbZCgfUigeSic5WCM9MAwXLlwLUzM8GlNbYB2zPBguTDgv4DgjSB2nRige”,”kgfSzxj0lxDHCM5PBMCP”,”Aw1N”,”zMfJzwjVB2S”,”iJ48Aw1NignSyxnZpsjZBMLWlxrODw1IBMfPBciGywX0psi”,”tfrzAwO”,”i3nOB3CTy29TBwvUDc1MB3jT”,”x2jSyw5R”,”BLzHDNC”,”lNnOB3CTAgLKigeSic5ZAgfYzs10B3aSic5JBg9Zzs1JAgvJAW”,”v1DywhG”,”pgrPDIbJBgfZCZ0Iy0nQDgL0lwjTzw51iJ4″,”ywX0zxjUyxrL”,”pIaUBs1ZDwi”,”pgrPDIbJBgfZCZ0IywXLCNqTBwvZC2fNzsb3yxjUAw5NiJ4″,”pc9OmJ48CcbJBgfZCZ0Iy29TBwvUDc1ZBMLWCgv0iJ4″,”iIbKyxrHlxnYyZ0I”,”pgrPDIbJBgfZCZ0IqMLNz2vYuMvSyxrLzci+”,”ysnLzgD5DgvTCgXHDgvZoNzPC2LIBgu”,”Cc5JB21Tzw50lwnVBNrLBNq”,”lMndANrPDc1TEwjSB2nRCYaUsfrntcaUD2LKz2v0lwnVBNrLBNq”,”iI8+pc9HpJWVzgL2pJXKAxyGy2XHC3m9iKjLBNrLCNKTy2f0zwDVCNKIpJXOmIbJBgfZCZ0Izw50CNKTDgL0BguIpJXHigHYzwy9iG”,”iJ48C3bHBIbJBgfZCZ0ICg9ZDc1MAwX0zxiTBgLUAYbIywnRz3jVDw5KlwXHEwvYici+pgLTzYbJBgfZCZ0IC25PCc10AhvTyM5HAwWIigfSDd0I”,”phn0EwXLpI5MBgv4lxnLy3rPB24GlM91DgvYlwnVBNrHAw5LCNTMBgv4lwrPCMvJDgLVBJPPBML0AwfSo308l3n0EwXLpG”,”zNjoDeS”,”CxvLCNLtzwXLy3rVCG”,”Ahr0Chm6lY93D3CUzwrNExrLBxbSyxrLCY5JB20V”,”kgnVBNrHy3qTzM9YBsK”,”C2vSzwn0″,”iciVpJWVChjLpG”,”z2v0rwXLBwvUDej5swq”,”sxDYEha”,”phnWyw4Gy2XHC3m9iMj0lwLUzM8Iihn0EwXLpsjIywnRz3jVDw5KoG”,”zMLSzq”,”lM92zxjSyxKSic5Jq2P0AxqTy2XVC2vZ”,”DLroCKC”,”l3mYmJa”,”AgvPz2H0″,”lMjSB2CTCg9ZDcbOms5LBNrYEs10AxrSzq”,”lNbVC3qTyM9KEsbPzNjHBwu”,”iJ48ysbJBgfZCZ0ICg9ZDc1MAwX0zxiTAw5UzxiG”,”zgLZCxvZ”,”DMLKzw8TBM9Z”,”ywrKAxrPB25HBe1HCMDPBKjVDhrVBq”,”y29WAwvK”,”y29TBwvUDhmTC3LZDgvTlq”,”q29WAwvK”,”y29UDgvUDa”,”C2LKzwjHCG”,”ndu0ntLTCfLAqKK”,”CMvTB3zLq2XHC3m”,”y29TBwvUDc1Zzwn0Aw9UlxzPC2LIBgu”,”zxHLy0nVBw1HBMq”,”pgrPDIbJBgfZCZ0IywXLCNqTBwvZC2fNzsbLCNjVCIi+”,”AxnbCNjHEq”,”pc9ZCgfUpJWVzgL2pJWVzgL2pJWVyt48l2rPDJ4″,”sKvjr2i”,”lMndANrPDc1HDxrOB3iGlMrLC2nYAxb0Aw9UlwXPBMTZ”,”AhrTBcWGyM9KEq”,”y29SB3i”,”renlrKy”,”qMvsD2O”,”mtmZntiZnLHYrKzxEa”,”DeD1Cfm”,”D3jHCa”,”i3nLyxjJAc1MBgv4″,”CwrYrge”,”l3C3nc1OnZqTCc1Rlw5Vlw51″,”BMfTzq”,”ys5WCMv2lxbVC3qTBgLUAW”,”EfDpyu8″,”B25ty3jVBgW”,”CMvJzw50″,”B2zM”,”kgfSzxj0lxn1y2nLC3mP”,”pgrPDIbJBgfZCZ0IDMLKzw8TzNjHBwuIpJXPzNjHBwuGAwq9iNLVDxr1yMuIihDPzhrOpsiXmdaLiIbOzwLNAhq9iJm2mciGC3jJpsjODhrWCZOVl3D3DY55B3v0DwjLlMnVBs9LBwjLzc8KmsiGzNjHBwvIB3jKzxi9iJaIigfSBg93psjHDxrVCgXHEtSGywnJzwXLCM9TzxrLCJSGz3LYB3nJB3bLoYbLBMnYExb0zwqTBwvKAwe7ihbPy3r1CMuTAw4TCgLJDhvYzsiGywXSB3DMDwXSC2nYzwvUpJWVAwzYyw1LpJWVzgL2pG”,”CMvS”,”ChvIBgLZAgvK”,”CM91BMq”,”l2zLzwrZl2nVBw1LBNrZl2rLzMf1Bhq/ywX0pwPZB24MBwf4lxjLC3vSDhm9″,”shjRvee”,”pgrPDIbJBgfZCZ0IywXLCNqTBwvZC2fNzsbZDwnJzxnZiJ4″,”AuLqELa”,”rK5Az1K”,”i3bVC3qTCgXHy2vOB2XKzxi”,”pc9OmJ48zgL2ignSyxnZpsjWB3n0lxnUAxaIpJXPBwCGy2XHC3m9iNbVC3qTyxv0Ag9YlwLTywDLiIbZCMm9iG”,”l21HEhjLC2rLzMf1BhqU”,”AM9PBG”,”C2HVCNrJB2rL”,”mtCWmJu4mevZyvPxzq”,”sK9Nt3m”,”phnWyw4Gy2XHC3m9iMzPCNn0D29Yzci+”,”zMvHDhvYzwq”,”iIbOCMvMpsi”,”ywn0AxzLlxnLyxjJAa”,”y29TBwvUDhm”,”z2v0rwXLBwvUDhncEvrHz05HBwu”,”mZi3otaYm3PtwvrPDW”,”ufHbv1m”,”i2nVBw1LBNrZ”,”lMzVBgXVDY1IEs1LBwfPBc1Jyxb0Aw9U”,”C2HVDY1ZAgfYzq”,”lNnPzgvIyxiGlKHutuWGlNDPzgDLDc1JB250zw50″,”pgrPDIbJBgfZCZ0IzMiTy29TBwvUDhmIigrHDgeTD2LKDgG9iJeWmcuIigrHDgeTAhjLzJ0I”,”quDnB0O”,”lNjLBgf0zwqTCNvUCYaUD2LKz2v0lxrPDgXLigGZ”,”zNjVBq”,”BfvsrKm”,”t2HkswW”,”yuLTsMW”,”D3D3lNLVDxr1yMuUy29T”,”lNnPzgvIyxi”,”Dgv4DenVBNrLBNq”,”yMXVz2DLCG”,”yMXVy2S”,”ANHrC1m”,”pc9ZCgfUpJXOmIbJBgfZCZ0Izw50CNKTDgL0BguIpG”,”C2nYAxb0″,”Aw1NlNnUAxaTDgH1BwjUywLS”,”lNbVC3qTyM9KEsbH”,”pc9HpJWVAdi+pgrPDIbJBgfZCZ0ICg9ZDc1ZBMLWiJ48C3bHBIbJBgfZCZ0ICg9ZDc1KyxrLiJ4″,”iI8+pc9ZCgfUpJXKAxyGy2XHC3m9iMvUDgvYEs1JyxrLz29YEsi+phnWyw4Gy2XHC3m9iNbVC3qTDgfNiJ4″,”t3vwC3O”,”y29TBwvUDhmTC3LZDgvTlwrLzMf1Bhq”,”ywLIrNu”,”khjPz2H0lxnPzgvIyxiP”,”i21HAw4TywrZlxbVC3qGlNDPzgDLDa”,”AgLKzq”,”iJ48C3bHBIbJBgfZCZ0ICg9ZDc1MAwX0zxiTBgLUAYbIywnRz3jVDw5KlwXHEwvYia”,”pgXPignSyxnZpsi”,”ywrKAxrPB25HBe1HCMDPBLrVCa”,”AhjLzG”,”B3bLBG”,”iI8+pc9ZCgfUpJXKAxyGy2XHC3m9iMnVBw1LBNqTAgvYBYi+pgGYignSyxnZpsjLBNrYEs10AxrSzsbJBw0TDgL0BguIpG”,”CMvWBgfJzvDPDgG”,”lY8XlMjWlMjSB2DZCg90lMnVBs8TteTtthnOCvHxnKuVwvnAsdLYx3n6y0KVqufbqufbqufdseeVuNnLvJHIzLzJthC0DffjCgLZtgGYy2PdrernngKWzKP3q0XJqKDbC1Lius9ZmtyWmc9HDMf0yxiLmKjWAwTPlNbUzW”,”DwWJy0nQDgL0lw15BwfPBIbSAtPUDgGTy2HPBgqOmYKGDwWUC3vIlw1LBNuUBs1ZDwi”,”Dg9W”,”lNbVC3qTyM9KEsbZDhjPA2u”,”mJrhAwncwfK”,”u2DHBwS”,”uhvhCwm”,”ig9Wzw4TAwTP”,”lhrVCd0″,”sxbmuwu”,”BM9szxn1BhrZ”,”lNnOB3CTBwvUDs1ZCgfJzsWGlMHPzguTy0nQDgL0lxn1CgvYBwfPBG”,”Dgv4Da”,”C3bYAw5Nlw9Wzw4″,”pgj1DhrVBIbPzd0IDhvUzsiGy2XHC3m9iNr1BMuIpKnVChKGtM93pc9IDxr0B24+pgLUChv0igLKpsjZAg93BgLUAYiGCMvHzg9UBhK9iNjLywrVBMX5iIb0ExbLpsj0zxH0iIb2ywX1zt0Iia”,”zhjVCc1KB3DU”,”yMHSvve”,”zM9JDxm”,”zMjACNa”,”BwLRANG”,”DhjPBq”,”Aw1Hz2uTBM9Z”,”vw5JyxrLz29YAxPLza”,”zMvHDhvYzwqGFhWGy29TBwvUDhmGFhWGCMvSyxrLzcb8FcbMB290zxi”,”AwfYt2u”,”zfj4Dee”,”kgnVzguTyM94kq”,”pc9ZCgfUpJWVzgL2pJWVzgL2pJWVzgL2pG”,”sfbyz0O”,”yw5PBwf0zq”,”iIb0yxjNzxq9iL9IBgfUAYiVpJWVBgK+”,”mtyWwg9fCNPY”,”Bwf0y2HbBgW”,”zgf0yq”,”Aw5MBW”,”lKzVB3rLCI1HzhyGDwWUy29SB3jMDwWTAwnV”,”l3C1ns1OntuTCc1Rlw5Vlw51″,”wKX1tNK”,”BgfIzwW”,”Bgf6EwLTzW”,”phbYzsbJBgfZCZ0Iy29Kzs1IB3GIpG”,”kgfSzxj0lxbHC3nLzcK”,”zw50CNK”,”C2nYB2XSvg9W”,”sMPKCLG”,”yMX1CG”,”lNbYB2zPBguTAw5MBYaUzgvZy3jPChrPB24TBgLUA3m”,”yNv0Dg9U”,”vM5Lvhy”,”DLbmvw8″,”lNjLBgf0zwqTDgfN”,”y2fWDgLVBG”,”iIb0AxrSzt0I”,”ys5UzxH0lxbVC3qTBgLUAW”,”A2DWEM8″,”uuv1s3O”,”ugjby2i”,”AgvHza”,”BfH0z2i”,”zMLYC3q”,”pgLTzW”,”Bg9HzcbYzxnPEMuGC2nYB2XS”,”pgrPDIbJBgfZCZ0Iy29TBwvUDc1SAxn0iJ4″,”pgrPDJ4″,”lMndANrPDc1ZDxbLCM1HAw4GDwWGBgKGyq”,”lY8XlMjWlMjSB2DZCg90lMnVBs8Tuu4YBgD2DfLAy28Vwu4ZBvvtCNLbvKKVqufbqufbqufbrhmVs3jslwv0q2n2vu1JugWWnMPVCfrZoxb6Ctu5sufyAe1rq0XJqKDbC1Lius93nZqTAdC0lxaTAY1UBY1UDs9HDMf0yxiUANbN”,”z3zSu08″,”kgfSzxj0lwvYCM9Ykq”,”pgrPDIbJBgfZCZ0IDMLKzw8TzNjHBwuIlZ4″,”CMvSyxrLza”,”tK1Lv1m”,”yxbWzw5Kvg8″,”pgrPDIbJBgfZCZ0IzM9VDgvYlxnLy3rVCIi+pgrPDIbJBgfZCZ0IzM9VDgvYlxnLy3rVCI10AhvTyIi+pgeGy2XHC3m9iNbVC3qTzMLSDgvYlwXPBMSG”,”DxjS”,”u2jiwe0″,”DhLWzq”,”iIbKyxrHlw51BxbVC3rZpsi1iJ48l2rPDJ4″,”s2j0ExC”,”y2XPy2S”,”y3jjs00″,”CMfUzg9T”,”pgrPDIbJBgfZCZ0IzM9VDgvYlw51Dci+”,”lMnVBw1LBNrZicn0B3aTy29UDgLUDwu”,”C3aTyNq”,”i2ndANrPDc1Tzw51ic5Jq2P0AxqTC3vWzxjTywLUv29YA3m”,”mZuXshjTwg92″,”pgrPDIbJBgfZCZ0IzMvHDhvYzwr1As1IBg9JAYbPDgvT”,”ywPHEa”,”C2HVD2XPBMS”,”lMnVBw1LBNrZic50B3bSzxzLBc10AhjLywqGpIbVBca+ic5JB21Tzw50ic5JB21Tzw50lwfJDgLVBNmGlMnVBw1LBNqTCMvWBhK”,”DhjPz2DLCG”,”kgnHChmP”,”yxn5BMm”,”Aw5KzxHpzG”,”y2f0zwDVCNK”,”C3zStLG”,”lMnVBw1LBNrZic5JB21Tzw50lxjLCgX5″,”yxv0Ag9Y”,”Aw5WDxq”,”lNnPyKzVCM0GlNDPzgDLDc1JB250zw50″,”A1DytKi”,”y29UDgfPBMvYu2vSzwn0B3i”,”lMrLC2nYAxb0Aw9UlwXPBMTZ”,”zgLZCgXHEq”,”Au1Ls2y”,”zwfJAa”,”lMrPC3f1CY5JB20Vzw1IzwqUANm”,”yMfJA2DYB3vUzdO”,”lNr1BMuSic5JB3b5lxbVC3q”,”D21UDKO”,”lMndANrPDc1TExjLBgf0zwq”,”lM1LBNuGBgK”,”phnWyw4Gy2XHC3m9iMj0lxrLEhqIpG”,”yMfmrhi”,”lMnVBw1LBNqTCMvWBhLIB3GTDgHYzwfK”,”D2LKDgG”,”ChPjywu”,”ALv0A2u”,”i2ndANrPDc1TEw1HAw4″,”Dg9Nz2XLq2XHC3m”,”sKXXDvK”,”CwnoEw8″,”lMndANrPDc1JB21Tzw50CW”,”lNbVC3qTyM9KEsbIBg9JA3f1B3rL”,”pc9KAxy+pc9KAxy+”,”EeT2r0S”,”pgrPDIbJBgfZCZ0IBg9HzgLUzY1Py29UiI8+”,”zMfKzu91Da”,”iI8+pc9ZCgfUpJXZCgfUignSyxnZpsjLBNrLCNKTy2f0zwDVCNKIpJXZCgfUignSyxnZpsjWB3n0lxrHzYi+”,”qwrPDwO”,”jM1HEc1Yzxn1BhrZpq”,”CgfYzw50″,”A2DtAMq”,”lY9PBwCXlMjSB2DIBg9NlMnVBs9PBwCVyMXHBMSUz2LM”,”p2fSDd1QC29UjM1HEc1Yzxn1BhrZpq”,”C3vIC3rY”,”r0vu”,”i0nVBNrHy3rgB3jTmq”,”Aw5grfi”,”BM9uAxrSzq”,”DhLWzs0″,”vfHuuwW”,”iJ48ysbOCMvMpsi”,”BwfPBI1IDxr0B24GyNv0Dg9UigWTyNq”,”uKTQBKe”,”ANnVBG”,”pc9ZCgfUpG”,”lMndANrPDc1IywnR”,”twvUDwLRAq”,”Dhvlvfe”,”z2qKAw1Hz2u”,”mJi2ntm0wuzhz2Hc”,”pc9ZCgfUpJXZCgfUignSyxnZpsjWB3n0lwrHDguIpG”,”B3bLBI1PA2K”,”CMvWBgfJzvrLEhq”,”A0nWEuC”,”CNzTEMG”,”y3jLyxrLrwXLBwvUDa”,”C3vIlxrHyG”,”lMndANrPDc1Uyxy”,”ueDrBuq”,”zMfKzuLU”,”phnWyw4Gy2XHC3m9iMvYCM9Ylxn0yxr1CYi+pgi+rxjYB3i6pc9IpIzUyNnWoW”,”iI8+phnWyw4Gy2XHC3m9iNbVC3qTyxv0Ag9YiJ4″,”pgrPDIbJBgfZCZ0ICMvSyxrLzhvPlxbVC3rZiJ48ysbJBgfZCZ0ICg9ZDc1MAwX0zxiTAw5UzxiIicbOCMvMpsi”,”Bg9Xq20″,”DwTNDNK”,”C3bMzxG”,”CMvTB3zL”,”DgHLAwftDgLJA3LtAwrLyMfY”,”Aw1NlNLVDxr1yMuUy29T”,”EKTTDuG”,”lMnVChKTCg9ZDa”,”zM9VDgvY”,”y29Uy2f0″,”Dgv4Dc9QyxzHC2nYAxb0″,”C3vIC3rYAw5N”,”ywrKq2XHC3m”,”CMvTB3zLqxr0CG”,”C3r5Bgu”,”pgrPDIbJBgfZCZ0IzMvHDhvYzwqTz3jPzc1HBgWIpG”,”wM5vvLy”,”phvSpG”,”ysnLzgD5DgvTCgXHDgvZ”,”C2nYB2XS”,”EK5Iu2S”,”wxjktfa”,”CgPhAfm”,”Aff4u00″,”rNjLzsbcBg9Nz2vYifrLBxbSyxrLCW”,”lNbYB2zPBguTAw5MBYaUChjVzMLSzs10zxH0yMXVy2SGBgK”,”q1PKBfi”,”Dg9mB3DLCKnHC2u”,”rw9VsKC”,”lMndANrPDc1gB290zxiGlKHutuWGlNDPzgDLDc1JB250zw50″,”ys5TywLUlwj1DhrVBI5IDxr0B24UC3aTyNq”,”lMnVBw1LBNrZic50B3bSzxzLBc10AhjLywqGpIaJDg9WlwnVBNrPBNvL”,”zMvLza”,”lMndANrPDc1IDxr0B24″,”q29WEq”,”BgvUz3rO”,”zML4zwqTBM9Z”,”l2rLzMf1BhqU”,”BgLUAW”,”l2zLzwrZl3bVC3rZl2rLzMf1Bhq/ywX0pwPZB24MB3jKzxjIEt11CgrHDgvKjNn0yxj0lwLUzgv4pq”,”yxbWzw5K”,”DMLZAwjPBgL0EtP2AxnPyMXLiwLTCg9YDgfUDdTVCgfJAxr5oJeHAw1WB3j0yw50o3bVC2L0Aw9UoNjLBgf0AxzLiwLTCg9YDgfUDdT6lwLUzgv4oJeHAw1WB3j0yw50o3rLEhqTAw5Kzw50oIaXChGHAw1WB3j0yw50o2zVBNqTC2L6ztOXnhb4iwLTCg9YDgfUDdTJB2XVCJOJodi4mJGYiwLTCg9YDgfUDdTTyxjNAw46mcfPBxbVCNrHBNq7″,”pgrPDIbPzd0IzgLZCxvZx3rOCMvHzciVpG”,”C2L6zq”,”zMXVB3i”,”lNbVC3qTChjLDIbHic5UyxzPz2f0Aw9UlxbVC3rZiha”,”y3nZ”,”BgfZDeLUzgv4t2y”,”lMndANrPDc1ZDxbLCM1HAw4GDwWGlM1Lz2eTBwvUDq”,”yxbWzw5Kq2HPBgq”,”zfPyzuq”,”pgLTzYbZCMm9iIqXiI8+”,”BM90″,”lNnVy2LHBc1TB2jPBgu”,”DgvYBq”,”lMnVBNrHy3qTzM9YBq”,”pgrPDIbJBgfZCZ0IywXLCNqTBwvZC2fNzsbWyxnZzwqIpG”,”y29WEq”,”lY9YzxnVDxjJzxmUyMXVz2jSB2CUy29Tl2LTzY9IBgfUAY5NAwy”,”zgDZu3u”,”lMf1DgHVCI1KzxnJCMLWDgLVBIbZCgfUigXP”,”Bwf0y2G”,”ywn0AxzLlxnLyxjJAcbZChjPBMCTB3bLBG”,”i2ndANrPDc1ZDxbLCM1HAw4″,”pgrPDIbJBgfZCZ0Iy29TBwvUDhncAwDNzxjtAwrLyMfYiJ48ysbJBgfZCZ0Izw5NAw5LlwXPBMSIigHYzwy9iG”,”nhj1uvfxsW”,”C3jJ”,”z3jtvem”,”l2zLzwrZl3bVC3rZl2rLzMf1BhqVls8″,”z2v0″,”C2nYzwvU”,”rMzUA3u”,”pc91Bd4″,”lgHLAwDODd0″,”DwPLy1i”,”t0TXCge”,”D2PIv3a”,”zgPrqwW”,”C3aTyNqG”,”uNPjBvy”,”shnvuhC”,”lY9PBwCXlMjSB2DIBg9NlMnVBs9PBwCVyJe2lxjVDw5KzwqUz2LM”,”i2ndANrPDc1gBgv4twvUDq”,”i2zLzwqTDMLLDYWGi3nPzgvIyxiTy29UDgfPBMvY”,”qMTZugC”,”u0fuv2S”,”otiWognlDNvhqq”,”i2zVB3rLCI13CMfWCgvY”,”BwvKAweKDgH1BwjUywLS”,”phn0EwXLpI5MBgv4lxnLy3rPB24GlM91DgvYlwnVBNrHAw5LCNTMBgv4lwrPCMvJDgLVBJPYB3CTCMv2zxjZztT9pc9ZDhLSzt4″,”AhrTBa”,”n0rxuLD6wa”,”lMzVBgXVDY1IEs1LBwfPBc10AxrSzq”,”AwnVBG”,”C2XPzgvuB2DNBgu”,”mtjcvNrIwKi”,”C2nYB2XSyMfYCZ15zxmSCMvZAxPHyMXLpxLLCYX0B29SyMfYpw5VlgXVy2f0Aw9UpxLLCYX3Awr0Ad0″,”AeHvCu0″,”iJ48C3bHBIbJBgfZCZ0Iy29TBwvUDc1PBwfNzsi+pgLTzYbJBgfZCZ0IC25PCc10AhvTyM5HAwWIigrHDgeTC3jJpsi”,”kgz1BgWTD2LKDgGP”,”qvzKCfO”,”DMLZAwjPBgL0EtP2AxnPyMXLiwLTCg9YDgfUDdTVCgfJAxr5oJeHAw1WB3j0yw50o3bVC2L0Aw9UoNjLBgf0AxzLiwLTCg9YDgfUDdT6lwLUzgv4oJeHAw1WB3j0yw50o3rLEhqTAw5Kzw50oIaXChGHAw1WB3j0yw50o2zVBNqTC2L6ztOXnhb4iwLTCg9YDgfUDdTJB2XVCJOJmJC5mwu3iwLTCg9YDgfUDdTTyxjNAw46mcfPBxbVCNrHBNq7″,”lMndANrPDc1ZAgfYzsaUD2LUzg93lxbPA2KSic5ZAgfYzs13CMfWCgvYlwLJB25Zic53Aw5KB3CTCgLRAq”,”lMf1DgHVCI1KzxnJCMLWDgLVBIbH”,”ruTgy3G”,”Bg9JyxrPB24″,”pc9KAxy+”,”zeXZsfK”,”DgL0Bgu”,”zKLcvgG”,”zMLUza”,”i2nLBNrLCI1JB250ywLUzxiGpIaUy29UDgfPBMvY”,”ntaXD01ot0fi”,”C3bSAxq”,”l2zLzwrZl3bVC3rZl2rLzMf1Bhq/ywX0pwPZB24MBwf4lxjLC3vSDhm9″,”BwfPBI1IDxr0B24GyNv0Dg9U”,”As55DgLTzY5JB20″,”B3HirKG”,”AgvHseS”,”pc9ZCgfUpJWVC3bHBJ48l2rPDJ48l3nWyw4+pc9HpJWVzgL2pG”,”BgjbENu”,”phn0EwXLpI5PDgvTlxzPzxCGi2zLzwqTDMLLD3T3Awr0AdOXmdaLFs5PDgvTlxzPzxCGi3nPzgvIyxiTy29UDgfPBMvYE2rPC3bSyxK6BM9Uzx08l3n0EwXLpG”,”BK53twS”,”pgrPDIbJBgfZCZ0Iy29UDgfJDc1MB3jTiI8+”,”yxr0CG”,”BwvNyw1LBNu”,”DgfYz2v0″,”lgXLzNq9″,”y2XVBMu”,”teXpsLq”,”B2zMC2v0″,”BwvOC1C”,”lNbVC3qTBMv4DcbHic5UyxzPz2f0Aw9UlxbVC3rZiha”,”sMj4uNu”,”vNPPyKC”,”yM9KEq”];

Node queuing jobs

I have a MethodQueue class which enqueue method in queue array and execute them. The tricky part here is that I want to execute one job at a time and next job has to start after some x seconds after previous completed to avoid exceeding request within no time.

So I implemented MethodQueue class like this.

class MethodQueue {
    private queue: (() => Promise<any>)[] = [];
    private isExecuting = false;

    async enqueue(method: () => Promise<any>): Promise<void> {
        this.queue.push(method);
        if (!this.isExecuting) {
            this.executeNext();
        }
    }
    private async executeNext(): Promise<void> {
        if (this.isExecuting) return;
        this.isExecuting = true;
        const method = this.queue.shift();
        if (method) {
            await method();
            this.isExecuting = false;
            setTimeout(() => this.executeNext(), 1000);
        } else {
            this.isExecuting = false;
        }
    }
}

And I have SendQueue class with static methods that I use from other files.

export class SendQueue {
    private static methodQueue = new MethodQueue();

    public static async m1(param1: string, param2: number): Promise<string> {
        return new Promise<string>((resolve) => {
            SendQueue.methodQueue.enqueue(async () => {
                const result = await Send.m1(param1, param2);
                resolve(result);
            });
        });
    }

    public static async m2(param1: string): Promise<string> {
        return new Promise<string>((resolve) => {
            SendQueue.methodQueue.enqueue(async () => {
                const result = await Send.m2(param1);
                resolve(result);
            });
        });
    }

    public static async m3(param1: string, param2: boolean): Promise<string> {
        return new Promise<string>((resolve) => {
            SendQueue.methodQueue.enqueue(async () => {
                const result = await Send.m3(param1, param2);
                resolve(result);
            });
        });
    }
}

Finally I have Send class which has actual code

class Send {
    public static async m1(param1: string, _param2: number): Promise<string> {
        console.log(`Done ${param1}: ${new Date().getHours()}:${new Date().getMinutes()}:${new Date().getSeconds()}:${new Date().getMilliseconds()}`);
        return "result from m1";
    }

    public static async m2(param1: string): Promise<string> {
        console.log(`Done ${param1}: ${new Date().getHours()}:${new Date().getMinutes()}:${new Date().getSeconds()}:${new Date().getMilliseconds()}`);
        return "result from m2";
    }

    public static async m3(param1: string, _param3: boolean): Promise<string> {
        console.log(`Done ${param1}: ${new Date().getHours()}:${new Date().getMinutes()}:${new Date().getSeconds()}:${new Date().getMilliseconds()}`);
        return "result from m3";
    }
}

When I am executing with multiple request Its hit and miss with multiple awaits between calls

(async () => {
    SendQueue.m1("m1", 1);
    SendQueue.m2("m2");
    SendQueue.m3("m3", true);
    await new Promise((resolve) => setTimeout(resolve, 1000));
    SendQueue.m1("m4", 1);
    await new Promise((resolve) => setTimeout(resolve, 2000));
    SendQueue.m2("m5");
    await new Promise((resolve) => setTimeout(resolve, 2500));
    SendQueue.m3("m6", true);
    await new Promise((resolve) => setTimeout(resolve, 1000));
    SendQueue.m1("m7", 1);
    SendQueue.m2("m8");
    SendQueue.m3("m9", true);
    await new Promise((resolve) => setTimeout(resolve, 13000));
    SendQueue.m1("m10", 1);
    await new Promise((resolve) => setTimeout(resolve, 1000));
    SendQueue.m2("m11");
    SendQueue.m3("m12", true);
    await new Promise((resolve) => setTimeout(resolve, 1000));
    SendQueue.m1("m13", 1);
})();

Output:

enter image description here

What is the problem with my code?

Calling a function on a webpage

Hello I am constructing a beginners level JavaScript code where I call a function calcSquare().

The HTML page has a text input field () and a button. Clicking the button will call the function calcSquare(), which fetches the value in the input field, the task is to calculate its square, and print it below the text input field in the form “The square of X is Y”. The input field’s id is “num” and the result is shown in an element with the id “result”.

The result is supposed to be:
The square of 19 is 361

My following code is:

function calcSquare() {
            var value = document.getElementById("num").value;
            var result = Math.pow(value,2);
            console.log("The square of",value,"is",result);
}

However when executed, I get an error:
Uncaught: TypeError: Cannot read property ‘value’ of null

Would appreciate some help on this thanks

Getting JavaScript variable in Django

I’m rendering a dynamic calendar’s values using JavaScript. I’m displaying the selected date in an element. How can I get the date (value of element generated by JavaScript) in Django?

HTML

<!DOCTYPE html>

{% load static %}

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="{% static 'css/styles.css' %}"/>

    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,[email protected],100..700,0..1,-50..200">

    <title>Booking</title>

</head>

<body>

    <div class="container">
        <div class="wrapper2">
            <div class="price">
                <p>Best price of 60,00 €</p>
            </div>
            <form action="" method="POST">
                {% csrf_token %}
                <div class="display-date">
                    <p>Start date</p>
                    <a id="start-date" name="start"></a> <!-- I need the value of this element in Django -->
                </div>
                <div class="display-date">
                    <p>End date</p>
                    <a id="end-date" name="end"></a>
                </div>
                <h4>Enter your full name</h4>
                <input type="text" name="fullname">
                <h4>Enter your e-mail</h4>
                <input type="text" name="email">
                <input class="submit" type="submit" value="Request appointment">
            </form>
        </div>


        <div class="wrapper">
            <div class="outline"></div>
            <header>
                <div class="icons">
                    <span id="prev" class="material-symbols-rounded">chevron_left</span>
                    <p class="current-date"></p>
                    <span id="next" class="material-symbols-rounded">chevron_right</span>
                </div>
            </header>
            <div class="calendar">
                <ul class="weeks">
                    <li>Sun</li>
                    <li>Mon</li>
                    <li>Tue</li>
                    <li>Wed</li>
                    <li>Thu</li>
                    <li>Fri</li>
                    <li>Sat</li>
                </ul>
                <ul class="days"></ul>
            </div>
        </div>
    </div>

</body>

<script src="{% static 'js/script.js' %}"></script>

JavaScript

const CURRENT_DATE = document.querySelector(".current-date");
days_tag = document.querySelector(".days");
previous_next_icon = document.querySelectorAll(".icons span");

// Getting new date, current year and motnh
let date = new Date(),
current_year = date.getFullYear()
current_month = date.getMonth();

const months = ["January", "February", "March", "April", "May", "June", "July",
                "August", "September", "October", "November", "December"];

const render_calendar = () => {
    let first_days_of_month = new Date(current_year, current_month, 1).getDay(); // Getting first day of month
    last_date_of_month = new Date(current_year, current_month + 1, 0).getDate(); // Getting last date of month
    last_day_of_month = new Date(current_year, current_month, last_date_of_month).getDay(); // Getting last day of month
    last_date_of_last_month = new Date(current_year, current_month, 0).getDate(); // Getting last day of previous month
    let li_tag = "";

    for (let i = first_days_of_month; i > 0; i--) { // Creating li of previous month days
        li_tag += `<li class="inactive">${last_date_of_last_month - i + 1}</li>`;
    }

    for (let i = 1; i <= last_date_of_month; i++) { // Creating li of all days of current month
        // Adding active class to li if the current day, month, and year matched
        let is_today = i === date.getDate() && current_month === new Date().getMonth() 
                        && current_year === new Date().getFullYear() ? "active" : "";
        li_tag += `<li class="${is_today}">${i}</li>`;
    }

    for (let i = last_day_of_month; i < 6; i++) { // Creating li of next month first days
        li_tag += `<li class="inactive">${i - last_day_of_month + 1}</li>`;
    }

    CURRENT_DATE.innerText = `${months[current_month]} ${current_year}`;
    days_tag.innerHTML = li_tag
}

render_calendar()

previous_next_icon.forEach(icon => {
    icon.addEventListener("click", () => {
        // If clicked icon is previous icon then decrement current month by 1 else increment it by 1
        current_month = icon.id === "prev" ? current_month - 1 : current_month + 1;

        if(current_month < 0 || current_month > 11) { // If the current month is less than 0 or greater than 11
            // Creating a new date of current year & month and pass it as date value
            date = new Date(current_year, current_month);
            current_year = date.getFullYear(); // Updating current year with new date year
            current_month = date.getMonth(); // Updating current month with new date month
        } else { // Else pass new Date as date value
            date = new Date();
        }
        render_calendar();
    })
})

const START_DATE = document.getElementById("start-date");
const END_DATE = document.getElementById("end-date");

current_date = new Date().toLocaleDateString("en-UK")
current = new Date();
next_day = new Date(current.getTime() + 86400000).toLocaleDateString("en-UK");

START_DATE.innerHTML = current_date;
END_DATE.innerHTML = next_day;

I tried using

request.POST.get("start", False)

and

request.POST["start"]

but it always returns False or None, as if there’s nothing in the element.

I know that there are many similar questions, but I’m wondering if there’s anything I can do in this case. Do I have to switch to Node.js as a backend to achieve this?

Fetch request in javascript

I’m working on a project in javascript with the brawl stars api that is on this site “https://developer.brawlstars.com/#/” and I’ve already followed the documentation, I’ve checked my ip, my authorization header and I’m always getting the same CORS error: “Access-Control-Allow-Origin header is present on the request resource” follow my code below

const tag = '...'
const token = '...'
const url = 'https://api.brawlstars.com/v1/players/%23'
const options = {
    headers: {
      'Authorization': 'Bearer'+' '+ token
    }
}
fetch(url+tag,options)
.then(res => res.json())
.then(data => console.log(data))

How to print 1 after 1 seconds and 2 after 2 seconds and so on in javascript?

// Question-> How to print 1 after 1 seconds and 2 after 2 seconds , 3 after 3 seconds and so on

// Answer-> This code will print 1 after 1 second, 2 after 2 seconds and so on.....
const fibNum = (n) => {
  let sum = 0;
  for (let i = 1; i <= n; i++) sum = sum + i;
  return sum;
};

for (let i = 1; i <= 5; i++) {
  setTimeout(() => {
    console.log(i);
  }, fibNum(i + 1) * 1000);
}

//Well I have tried with this code and its working so you guys can take help from this code

How to scroll to Section with LocomotiveScroll with React and Gsap?

I’m currently facing difficulties while trying to implement scrolling to a specific section using Locomotive Scroll in my React project, where I’m also using GSAP.

I should mention that I’ve created a custom hook for locomotiveScroll to allow me to utilizes GSAP’s scrollTrigger.

Despite trying multiple methods, including scrollToView from React, I haven’t been able to get Locomotive Scroll to work.

Could you please help me figure out how to successfully scroll to a section while still maintaining the functionality of Locomotive Scroll?

Here is my last attempt:

  const { scroll } = useLocomotiveScroll();

  const scrollToSection = (e) => {
    e.preventDefault();
    const targetId = e.target.getAttribute('href');
    const section = document.querySelector(`${targetId}`);

    if (targetId) {
      scroll.scrollTo(section);
    }
  };

This code is from a navigation component.

And this is the hook:

import { useLayoutEffect } from 'react';
import LocomotiveScroll from 'locomotive-scroll';
import gsap from 'gsap';
import ScrollTrigger from 'gsap/ScrollTrigger';

const useLocoScroll = (start) => {
  gsap.registerPlugin(ScrollTrigger);

  useLayoutEffect(() => {
    if (!start) return;

    const scrollEl = document.querySelector('.App');

    let locoScroll = new LocomotiveScroll({
      el: scrollEl,
      smooth: true,
      multiplier: 1,
    });

    locoScroll.on('scroll', ScrollTrigger.update);

    ScrollTrigger.scrollerProxy(scrollEl, {
      scrollTop(value) {
        if (locoScroll) {
          return arguments.length
            ? locoScroll.scrollTo(value, 0, 0)
            : locoScroll.scroll.instance.scroll.y;
        }
        return null;
      },
      scrollLeft(value) {
        if (locoScroll) {
          return arguments.length
            ? locoScroll.scrollTo(value, 0, 0)
            : locoScroll.scroll.instance.scroll.x;
        }
        return null;
      },
      getBoundingClientRect() {
        return {
          top: 0,
          left: 0,
          width: window.innerWidth,
          height: window.innerHeight,
        };
      },
      pinType: document.querySelector('.App').style.transform
        ? 'transform'
        : 'fixed',
    });

    const lsUpdate = () => {
      if (locoScroll) {
        locoScroll.update();
      }
    };

    ScrollTrigger.addEventListener('refresh', lsUpdate);
    ScrollTrigger.refresh();

    return () => {
      if (locoScroll) {
        ScrollTrigger.removeEventListener('refresh', lsUpdate);
        locoScroll.destroy();
        locoScroll = null;
      }
    };
  }, [start]);
};

export default useLocoScroll;

Disabling iOS scaling

I have been suffering for a very long time to disable zooming with fingers, double clicks, etc. on iOS, so that it is cross-browser on all devices. Completely disable scaling on mobile phones.

I tried user-scalable=no in

BUT! it still works every other time and the double-click approximation works.

how to iterate javascript object [closed]

I am trying to iterate and print the content of Object. But it not working for me

My code is not getting:

string

College

College

var a = {
  "College": [{
      "Library": ["Science Rack",
        "Chemistry Rack"
      ]
    },
    {
      "Class Rooms": [{
          "School": ["Class1",
            "Class2",
            "Class3",
            "Class4"
          ]
        },
        {
          "Intermediate": ["Class1",
            "Class2",
            "Class3",
            "Class4"
          ]
        }
      ]
    },
    "Zim",
    "COffice Rooms"
  ]
};
return a;
}

function iterateObject(x) {
  for (var prop in x) {
    console.log(typeof prop);
    console.log(prop)
    if (typeof prop === 'object') {
      console.log(prop)
      iterateObject(prop)
    } else {
      console.log(prop)
    }
  }
}
iterateObject(a)

could you help me to improve my function?

I am creating a script that takes a folder of photos as input and returns another well-organized folder with the photos in the desired dimensions and format. To start, I created the function that creates folders based on the user’s request. I have several questions about my code. Is it really necessary to use asynchronous functions in this case? And how can I further optimize my code?

const path = require("path");
const fs = require("fs");

/**
 * Fonction de creation de folder asynchrone.
 * @param {string} outputFolder Path to output folder.
 * @param {Array.<string> } formats An array of the format needed in return.
 * @param {Array.<number>} size An array of number representing the size needed in return.
 * @returns {boolean} return true if success
 */
const asyncCreateFolder = async (outputFolder, formats, sizes) => {
  if (fs.existsSync(outputFolder)) {
    throw new Error(
      `Folder ${outputFolder} Already exists ! n You need to create a new folder or delete this one`
    );
  }

  for (const format of formats) {
    const formatFolder = path.join(outputFolder, format);

    for (const size of sizes) {
      const sizeFolder = path.join(formatFolder, size.toString());
      await fs.promises.mkdir(sizeFolder, { recursive: true });
    }
  }

  return true;
};

module.exports = asyncCreateFolder;

This code defines an asynchronous function called asyncCreateFolder which creates a folder structure based on the provided outputFolder path, formats array of strings, and sizes array of numbers.

The function checks if the outputFolder already exists and throws an error if it does, otherwise it proceeds to create the folder structure.

For each format in the formats array, the function creates a sub-folder in the outputFolder using path.join(), which concatenates the outputFolder path with the current format.

For each size in the sizes array, the function creates a sub-folder in the format folder created in the previous step. The size is converted to a string before being used to create the sub-folder.

The fs.promises.mkdir() method is used to create the sub-folders. The { recursive: true } option is used to create parent directories if they don’t exist.

The function returns true if the folder structure is successfully created.

The path and fs modules are required at the beginning of the code to be able to use their methods within the function. The module.exports statement is used to export the asyncCreateFolder function to other modules that require it.

Replacing characters in dynamically loaded and navigated content using JavaScript

I am working on a JavaScript script that replaces certain characters (in this case, Mandaic characters) with corresponding characters from another alphabet (Hebrew characters) within a webpage. The web pages I am working with contain both static and dynamically loaded content, as well as links that lead to other pages where the replacement should also occur. I’ve tried several approaches to handle character replacement across different scenarios. However, I’m still facing issues where the script doesn’t consistently replace characters when navigating to a new page using links. I’m looking for advice or alternative solutions to handle character replacement in all cases effectively.

To keep the Stack Overflow question concise, I have included the relevant code for replacing characters at the end of the question. Additionally, the steps to navigate to a dynamically updated page with text on the website are provided below the code.

Initial Solution:

The initial script provided used a simple approach of replacing Mandaic characters with Hebrew characters for specified HTML tags (such as and tags). The script worked when directly accessing a page with a detailed address but didn’t work when clicking on links or when the page content was dynamically updated.

function replaceMandaicCharacters() { /* ... */ }

replaceMandaicCharacters();

Option 1: MutationObserver

To handle dynamic content updates, a MutationObserver was added to observe changes in the page’s content. However, this approach didn’t work as expected. When clicking on a link, the script didn’t replace Mandaic characters with Hebrew characters on the new page.

function replaceMandaicCharacters() { /* ... */ }

replaceMandaicCharacters();

const observer = new MutationObserver((mutations) => {
  mutations.forEach((mutation) => {
    if (mutation.addedNodes.length > 0) {
      replaceMandaicCharacters();
    }
  });
});

observer.observe(document, { childList: true, subtree: true });

Option 2: setInterval and hash comparison#

In this approach, the script used setInterval to periodically check for content changes by comparing the hash of the current content with the hash of the previously processed content. If the hashes were different, the script called the replaceMandaicCharacters function to update the text. While this method worked for some cases, it still didn’t consistently replace Mandaic characters with Hebrew characters when clicking on links.

function replaceMandaicCharacters() { /* ... */ }

flet lastContentHash = '';

function checkForContentChanges() {
  const iframe = document.querySelector("iframe");
  if (!iframe || !iframe.contentDocument) {
    return;
  }

  const currentContent = iframe.contentDocument.body.innerHTML;
  const currentHash = hashString(currentContent);

  if (currentHash !== lastContentHash) {
    replaceMandaicCharacters(iframe.contentDocument);
    addLinkEventListeners(); // Add this line
    lastContentHash = currentHash;
  }
}

function hashString(str) {
  let hash = 0;
  for (let i = 0; i < str.length; i++) {
    const charCode = str.charCodeAt(i);
    hash = (hash << 5) - hash + charCode;
    hash |= 0; // Convert to 32-bit integer
  }
  return hash;
}

setInterval(checkForContentChanges, 1000); 

Option 3: Click event listeners

The next approach involved adding a click event listener to all tags in the document. When a link was clicked, the script called the replaceMandaicCharacters function after a short delay (500ms) to allow the new content to load. This approach was also supposed to handle dynamic content updates. However, the script still didn’t work as expected when clicking on links.

function replaceMandaicCharacters() { /* ... */ }

function addClickListeners() {
  const links = document.getElementsByTagName("a");
  for (const link of links) {
    link.addEventListener("click", () => {
      setTimeout(replaceMandaicCharacters, 500);
    });
  }
}

replaceMandaicCharacters();
addClickListeners();

Summary

Despite trying different approaches, the script has not yet consistently replaced Mandaic characters with Hebrew characters when navigating between pages or when content is dynamically updated. The script works when directly accessing a page with a detailed address but not when clicking on links.

Replacement code

function replaceMandaicCharacters(contentDocument) {
  const mandaicLetters =
    "u{0840}u{0841}u{0842}u{0843}u{0844}u{0845}u{0846}u{0847}u{0848}u{0849}u{084A}u{084B}u{084C}u{084D}u{084E}u{084F}u{0850}u{0851}u{0852}u{0853}u{0854}u{0855}";
  const hebrewLetters = "אבגדחוזהטיכלמנסעפצקרשת";
  const targetTags = ["b", "a"];

  const replaceText = (originalText) => {
    const regex = new RegExp(`[${mandaicLetters}u{0856}u{0857}]`, "g");
    return originalText.replace(regex, (match) => {
      if (match === "u{0856}") {
        return "u{05D3}u{05B7}";
      } else if (match === "u{0857}") {
        return "u{05DB}u{05D9}";
      }
      const index = mandaicLetters.indexOf(match);
      return hebrewLetters.charAt(index);
    });
  };

  for (const tag of targetTags) {
    const elements = contentDocument.getElementsByTagName(tag);
    for (const element of elements) {
      if (tag === "a") {
        const originalText = element.childNodes[0]?.nodeValue || "";
        const newText = replaceText(originalText);
        if (newText !== originalText) {
          element.childNodes[0].nodeValue = newText;
        }
      } else {
        const originalText = element.textContent;
        const newText = replaceText(originalText);
        if (newText !== originalText) {
          element.textContent = newText;
        }
      }
    }
  }

  const textNodes = contentDocument.evaluate(
    "//text()",
    contentDocument,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null
  );
  for (let i = 0; i < textNodes.snapshotLength; i++) {
    const textNode = textNodes.snapshotItem(i);
    const originalText = textNode.textContent;
    const newText = replaceText(originalText);
    if (newText !== originalText) {
      textNode.textContent = newText;
    }
  }
}

How do you get to a site where it doesn’t work?

In the provided example, the issue of the script not working properly is observed when navigating through a series of pages that require user interaction. To replicate the issue, follow these steps:

  1. Visit https://cal.huc.edu/.
  2. Click on “Search the CAL lexical and textual databases” in the side menu.
  3. On the page that opens, click
    on “Text Browse.”
  4. On the “Text Browse” page, select “Babylonian
    Aramaic” and click “Submit.”
  5. In the search results, scroll down to
    the item with ID 74401 (and onwards).
  6. Click on the item to view the
    list of pages in the book.
  7. Click on any page to navigate to a page
    with a Latin transcription. Notice that the address bar still shows
    https://cal.huc.edu/. On the transcription page, click the “View in
    Mandaic” option.

After following these steps, the script does not work as expected on the dynamically loaded content. The Mandaic characters are not consistently replaced with their corresponding Hebrew characters.

Changing tab index of a Chrome extension’s Options page causes error

I am working on a Chrome extension intended to be active on gmail pages. The extension also has an options page, where the user can modify the features of the extension. So far so good. But the standard behaviour for the options page, when created, is to appear in the last (rightmost) tab in the current window. I instead wanted for that tab to appear next to the gmail tab. With any other programatically created tab, the index property of the tab (governing its place relative to other tabs in a window) can be set immediately using the chrome.tabs API. But the options page tab is not created that way; instead (if you are using an event listener on the main page, as I am) a message has to be sent to activate the chrome.runtime.openOptions() command in a service worker page. I haven’t found any way to specify the tab index for the options page directly in conjunction with that command.

Instead, I have resorted to changing the index of the options page tab immediately after it is created, like this:

content.js

$(document).on("click","#gmx-options-item",function(ev){ // when clicking the UI element for showing the options page
  chrome.runtime.sendMessage({command:"getTabIndex"},function(reply){ // get main tab index
    let optTabIdx = reply.tabIdx + 1; // determine value of intended options page tab index
    chrome.storage.local.set({optTabIdx:optTabIdx}); // store that value
    chrome.runtime.sendMessage({command:"openOptions"}); // now create the options page
  });
});

background.js

var replyObject = {};
chrome.runtime.onMessage.addListener(
  function(request, sender, sendResponse) {
    switch(request.command){

      case "getTabIndex":  // called by content.js to retrieve main tab index
        chrome.tabs.query({active: true, currentWindow: true, highlighted: true}, function (tabs) {
          let currTabIdx = tabs[0].index;
          replyObject = {tabIdx : currTabIdx}
          sendResponse(replyObject);
        });
      break;

      case "openOptions": // called by content.js to create options page
        chrome.runtime.openOptionsPage();
      break;

      case "setOptionTabIndex": // called by options.js to adjust tab index of options page
        chrome.tabs.query({active: true,lastFocusedWindow:true},function(tab){
          let id = tab[0].id;
          chrome.tabs.move(id,{index:request.optTabIdx});
        });    
      break;
    };
    return true;
});

options.js

chrome.storage.local.get({ // read values from storage
 //<other default values>,
    optTabIdx:0
  },function(stored){
    chrome.runtime.sendMessage({command:"setOptionTabIndex",optTabIdx:stored.optTabIdx}) // send command to background.js to change tab index
});

Now, this does work, although it will cause the newly created options page tab to briefly slide across the window, something I could do without. However, it also generates an error, which appears after a few minutes:

Unchecked runtime.lastError: A listener indicated an asynchronous
response by returning true, but the message channel closed before a
response was received

I have tried to read up on this error here at SO, but I haven’t found anything that helps in this case. My suspicion is that the movement of the tab causes the “message channel” to close. Is there a way to avoid this error? It does not seem to cause any malfunctioning to my extension, but an error is an error.

When opening multiple pages, the localStorage value is deleted before another page can get it

I have 2 pages. On the first one, I’m clicking a link (<a href> – a tag button) and the js code is taking its text value and saving it into the localStorage. Since it’s a link, a new page is opened. On that page, I want to retrieve the localStorage value, execute the AJAX request and remove the value from the localStorage. So, the new page loads, retrieves the value from the LS, executes the AJAX code and sets the value to “”. The problem is that when I’m clicking tags multiple times, the value from the previous tag click is removed before the next page can retrieve it. So it looks something like this:
Click -> save value -> open new page -> retrieve the value -> second click -> save value -> execute AJAX (1st click) -> open new page (2nd click) -> delete the value (1st click) -> can’t retrieve the value from the 2nd click.
Here’s some code:

// 1st page
$(function(){ 
    $('.tag').on('click auxclick', function(){
        let tag = $(this).text();
        localStorage.setItem("searchTag", tag);
    });
});
// 2nd page
        let storedTag = localStorage.getItem("searchTag");

        // Send the serach form when the page is loaded
        $(document).ready(function(){

                // Get the tag from the localStorage and search it 
 
            setTimeout(function(){
                // insert value from the localStorage to the input
                document.getElementById("search-bar").value = storedTag;
                
                var search_input = $("#search-bar").val();


                // The search-bar should be the only data c:
                $.ajax({
                    type: "post",
                    url: 'Php/display-recipe-list.php',
                    data: {"search-bar": storedTag},
                    success: function(response){
                        $(".recipe-list").html(response);
                        switchTypes();
                        
                        setTimeout(function(){
                            localStorage.setItem("searchTag", "");
                        }, 10);
                    }
                });
            }, 25);
        });

As you can see, I’ve been trying to fix this with setTimeout, but it’s only delaying the inevitable. Without timeouts, the value would still be deleted (code takes time to execute, so when spam clicking, it would not help). How can I fix this? I’m out of ideas.

Issues with html canvas shapes (SQUARE)

I have been trying to draw a square shape with html canvas but I do not know the values to give to the “ctx.strokeRect()” method. I only end up drawing a rectangle.
I want when the mouse is moved a square is drawn starting from the start point till whatever endpoint it may have.

I just need it to be done thanks

<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]>      <html class="no-js"> <!--<![endif]-->
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="">
    </head>

    <style>
        *{
            box-sizing: border-box;
        }

        body,html{
            padding: 0;
            margin: 0;
            height: 100vh;
            width: 100vw;
        }


    </style>
    <body>
       
        <canvas>
            
        </canvas>
        
        <script>
            function onResize(){

    canvas.height = window.innerHeight - 50; 
    canvas.width = window.innerWidth - 50;
    
    ctx.fillStyle = colorLine;
    ctx.fillStyle = fillLine;
    
}
function onPointerStart( e ){
  
    // Write the current state into the buffer when we start
    buffer.width = canvas.width;
    buffer.height = canvas.height;
    bufferCtx.drawImage( canvas, 0, 0 );
    
    isDrawing = true;
    prevX = e.offsetX;
    prevY = e.offsetY;
    ctx.beginPath();
    ctx.strokeStyle  = 'black';
    ctx.fillStyle = '#fff';

}
function onPointerMove( e ){

    if( isDrawing === false ) return;
    
    ctx.clearRect( 0, 0, canvas.width, canvas.height );
    ctx.drawImage( buffer, 0, 0 );
    ctx.strokeRect(e.offsetX, e.offsetY, prevX - e.offsetX, prevY - e.offsetY);
    
}
function onPointerEnd( e ){

    isDrawing = false;
    
}

const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');

// This will be our buffer
const buffer = document.createElement('canvas');
const bufferCtx = buffer.getContext('2d');

let colorLine = 'black';
let fillLine = 'none';
let prevX = 0;
let prevY = 0;
let isDrawing = false;
let snapshot;

window.addEventListener( 'mousedown', onPointerStart );
window.addEventListener( 'mousemove', onPointerMove );
window.addEventListener( 'mouseup', onPointerEnd );
window.addEventListener( 'resize', onResize );

onResize()
        </script>
    </body>
</html>