Best JavaScript code snippet using playwright-internal
languages.js
Source:languages.js
1// languages.js - jlozano developer Copyright (c) | jlozano.net/license - Version 1.7 234// Languages5 6$("#language_bt").click(function(){7 $("#languagemodal").fadeIn(100);8 $('#languagemodal').animate({left:'0%'}, 200, 'swing', function() {}); 9 $("ul.listlanguages").animate({ scrollTop: 0 }, 100);10 return false;11});1213$("#languageclose").click(function(){14 $('#languagemodal').animate({left:'+=100%'}, 200, 'swing', function() {}); 15});1617// Reset search 1819$(".resetsearch").click(function() {20 $(".languagesearch").val("");21 $('.notfound').hide();22 $('.listlanguages li').fadeIn(100);23 $(".resetsearch").hide();24});2526 27// Input reset2829$(".languagesearch").keyup(function(event){30 var val = $(this).val();31 if (val.length > 0){32 $(".resetsearch").show();33 }34 else{35 $(".resetsearch").hide();36 } 37});38 39 40// Order - list languages4142var $list = $("#list");4344$list.children().detach().sort(function(a, b) {45 return $(a).text().localeCompare($(b).text());46}).appendTo($list);474849// Search language 5051$('#languagesearch').bind('keyup', function() {52 var searchString = $(this).val();53 var count = 0;54 $(".listlanguages li").each(function(index, value) {55 currentName = $(value).text()56 if( currentName.toUpperCase().indexOf(searchString.toUpperCase()) > -1) {57 $(value).show();58 count++;59 }60 else{61 $(value).hide();62 } 63 });64 if (count != 0) 65 {66 $('.listlanguages').find('.notfound').hide();67 }68 else{69 $('.listlanguages').find('.notfound').show();70 } 71});7273// Save selected language7475savelanguage = function () {76 $('.configuration-settings').hide(); 77 $('.configuration_active').addClass('configuration'); 78 $('.configuration').removeClass('configuration_active');79 localStorage.setItem('Configuration', 'off'); 80 $('body').addClass('height_auto'); 81 $('body').removeClass('height_500'); 82 $('body').removeClass('height_500_2'); 83 window.top.location.reload();84};8586$(document).ready(function() {8788// de - German8990DE = function () {91 localStorage.setItem('Language', 'de');92 $('#selectedlanguage').text(de);93 $('.listlanguages li a').removeClass('active');94 $('#bt_de').addClass('active');95 $('#list').find('#li_de').insertBefore('li:eq(0)'); 96};9798// bn - Bengali99100BN = function () {101 localStorage.setItem('Language', 'bn');102 $('#selectedlanguage').text(bn);103 $('.listlanguages li a').removeClass('active');104 $('#bt_bn').addClass('active'); 105 $('#list').find('#li_bn').insertBefore('li:eq(0)'); 106};107108// bg - Bulgarian109110BG = function () {111 localStorage.setItem('Language', 'bg');112 $('#selectedlanguage').text(bg);113 $('.listlanguages li a').removeClass('active');114 $('#bt_bg').addClass('active'); 115 $('#list').find('#li_bg').insertBefore('li:eq(0)'); 116};117118// ca - Catalan119120CA = function () {121 localStorage.setItem('Language', 'ca');122 $('#selectedlanguage').text(ca);123 $('.listlanguages li a').removeClass('active');124 $('#bt_ca').addClass('active'); 125 $('#list').find('#li_ca').insertBefore('li:eq(0)'); 126};127128// cs - Czech129130CS = function () {131 localStorage.setItem('Language', 'cs');132 $('#selectedlanguage').text(cs);133 $('.listlanguages li a').removeClass('active');134 $('#bt_cs').addClass('active'); 135 $('#list').find('#li_cs').insertBefore('li:eq(0)'); 136};137138// zh_CN - Chinese (China)139140ZH_CN = function () {141 localStorage.setItem('Language', 'zh_CN');142 $('#selectedlanguage').text(zh_CN);143 $('.listlanguages li a').removeClass('active');144 $('#bt_zh_CN').addClass('active');145 $('#list').find('#li_zh_CN').insertBefore('li:eq(0)'); 146};147148// zh_TW - Chinese (Taiwan)149150ZH_TW = function () {151 localStorage.setItem('Language', 'zh_TW');152 $('#selectedlanguage').text(zh_TW);153 $('.listlanguages li a').removeClass('active');154 $('#bt_zh_TW').addClass('active'); 155 $('#list').find('#li_zh_TW').insertBefore('li:eq(0)'); 156};157158// ko - Korean159160KO = function () {161 localStorage.setItem('Language', 'ko');162 $('#selectedlanguage').text(ko);163 $('.listlanguages li a').removeClass('active');164 $('#bt_ko').addClass('active'); 165 $('#list').find('#li_ko').insertBefore('li:eq(0)'); 166};167168// hr - Croatian169170HR = function () {171 localStorage.setItem('Language', 'hr');172 $('#selectedlanguage').text(hr);173 $('.listlanguages li a').removeClass('active');174 $('#bt_hr').addClass('active'); 175 $('#list').find('#li_hr').insertBefore('li:eq(0)'); 176};177178// da - Danish179180DA = function () {181 localStorage.setItem('Language', 'da');182 $('#selectedlanguage').text(da);183 $('.listlanguages li a').removeClass('active');184 $('#bt_da').addClass('active'); 185 $('#list').find('#li_da').insertBefore('li:eq(0)'); 186};187188// sk - Slovak189190SK = function () {191 localStorage.setItem('Language', 'sk');192 $('#selectedlanguage').text(sk);193 $('.listlanguages li a').removeClass('active');194 $('#bt_sk').addClass('active'); 195 $('#list').find('#li_sk').insertBefore('li:eq(0)'); 196};197198// sl - Slovenian199200SL = function () {201 localStorage.setItem('Language', 'sl');202 $('#selectedlanguage').text(sl);203 $('.listlanguages li a').removeClass('active');204 $('#bt_sl').addClass('active');205 $('#list').find('#li_sl').insertBefore('li:eq(0)'); 206};207208// es - Spanish209210ES = function () {211 localStorage.setItem('Language', 'es');212 $('#selectedlanguage').text(es);213 $('.listlanguages li a').removeClass('active');214 $('#bt_es').addClass('active'); 215 $('#list').find('#li_es').insertBefore('li:eq(0)'); 216};217218// et - Estonian219220ET = function () {221 localStorage.setItem('Language', 'et');222 $('#selectedlanguage').text(et);223 $('.listlanguages li a').removeClass('active');224 $('#bt_et').addClass('active');225 $('#list').find('#li_et').insertBefore('li:eq(0)'); 226};227228// fil - Filipino229230FIL = function () {231 localStorage.setItem('Language', 'fil');232 $('#selectedlanguage').text(fil);233 $('.listlanguages li a').removeClass('active');234 $('#bt_fil').addClass('active'); 235 $('#list').find('#li_fil').insertBefore('li:eq(0)'); 236};237238// fi - Finnish239240FI = function () {241 localStorage.setItem('Language', 'fi');242 $('#selectedlanguage').text(fi);243 $('.listlanguages li a').removeClass('active');244 $('#bt_fi').addClass('active');245 $('#list').find('#li_fi').insertBefore('li:eq(0)'); 246};247248// fr - French249250FR = function () {251 localStorage.setItem('Language', 'fr');252 $('#selectedlanguage').text(fr);253 $('.listlanguages li a').removeClass('active');254 $('#bt_fr').addClass('active'); 255 $('#list').find('#li_fr').insertBefore('li:eq(0)'); 256};257258// el - Greek259260EL = function () {261 localStorage.setItem('Language', 'el');262 $('#selectedlanguage').text(el);263 $('.listlanguages li a').removeClass('active');264 $('#bt_el').addClass('active'); 265 $('#list').find('#li_el').insertBefore('li:eq(0)'); 266};267268// gu - Gujarati269270GU = function () {271 localStorage.setItem('Language', 'gu');272 $('#selectedlanguage').text(gu);273 $('.listlanguages li a').removeClass('active');274 $('#bt_gu').addClass('active'); 275 $('#list').find('#li_gu').insertBefore('li:eq(0)'); 276};277278// he - Hebrew279280HE = function () {281 localStorage.setItem('Language', 'he');282 $('#selectedlanguage').text(he);283 $('.listlanguages li a').removeClass('active');284 $('#bt_he').addClass('active'); 285 $('#list').find('#li_he').insertBefore('li:eq(0)'); 286};287288// hi - Hindi289290HI = function () {291 localStorage.setItem('Language', 'hi');292 $('#selectedlanguage').text(hi);293 $('.listlanguages li a').removeClass('active');294 $('#bt_hi').addClass('active'); 295 $('#list').find('#li_hi').insertBefore('li:eq(0)'); 296};297298// nl - Dutch299300NL = function () {301 localStorage.setItem('Language', 'nl');302 $('#selectedlanguage').text(nl);303 $('.listlanguages li a').removeClass('active');304 $('#bt_nl').addClass('active'); 305 $('#list').find('#li_nl').insertBefore('li:eq(0)'); 306};307308// hu - Hungarian309310HU = function () {311 localStorage.setItem('Language', 'hu');312 $('#selectedlanguage').text(hu);313 $('.listlanguages li a').removeClass('active');314 $('#bt_hu').addClass('active');315 $('#list').find('#li_hu').insertBefore('li:eq(0)'); 316};317318// id - Indonesian319320ID = function () {321 localStorage.setItem('Language', 'id');322 $('#selectedlanguage').text(id);323 $('.listlanguages li a').removeClass('active');324 $('#bt_id').addClass('active'); 325 $('#list').find('#li_id').insertBefore('li:eq(0)'); 326};327328// en_US - English (USA)329330EN_US = function () {331 localStorage.setItem('Language', 'en_US');332 $('#selectedlanguage').text(en_US);333 $('.listlanguages li a').removeClass('active');334 $('#bt_en_US').addClass('active'); 335 $('#list').find('#li_en_US').insertBefore('li:eq(0)'); 336};337338// en_GB - English (Great Britain)339340EN_GB = function () {341 localStorage.setItem('Language', 'en_GB');342 $('#selectedlanguage').text(en_GB);343 $('.listlanguages li a').removeClass('active');344 $('#bt_en_GB').addClass('active'); 345 $('#list').find('#li_en_GB').insertBefore('li:eq(0)'); 346};347348// it - Italian349350IT = function () {351 localStorage.setItem('Language', 'it');352 $('#selectedlanguage').text(it);353 $('.listlanguages li a').removeClass('active');354 $('#bt_it').addClass('active'); 355 $('#list').find('#li_it').insertBefore('li:eq(0)'); 356};357358// ja - Japanese359360JA = function () {361 localStorage.setItem('Language', 'ja');362 $('#selectedlanguage').text(ja);363 $('.listlanguages li a').removeClass('active');364 $('#bt_ja').addClass('active');365 $('#list').find('#li_ja').insertBefore('li:eq(0)'); 366};367368// lv - Latvian369370LV = function () {371 localStorage.setItem('Language', 'lv');372 $('#selectedlanguage').text(lv);373 $('.listlanguages li a').removeClass('active');374 $('#bt_lv').addClass('active'); 375 $('#list').find('#li_lv').insertBefore('li:eq(0)'); 376};377378// lt - Lithuanian379380LT = function () {381 localStorage.setItem('Language', 'lt');382 $('#selectedlanguage').text(lt);383 $('.listlanguages li a').removeClass('active');384 $('#bt_lt').addClass('active'); 385 $('#list').find('#li_lt').insertBefore('li:eq(0)'); 386};387388// ms - Malay389390MS = function () {391 localStorage.setItem('Language', 'ms');392 $('#selectedlanguage').text(ms);393 $('.listlanguages li a').removeClass('active');394 $('#bt_ms').addClass('active'); 395 $('#list').find('#li_ms').insertBefore('li:eq(0)'); 396};397398// mr - Marathi399400MR = function () {401 localStorage.setItem('Language', 'mr');402 $('#selectedlanguage').text(mr);403 $('.listlanguages li a').removeClass('active');404 $('#bt_mr').addClass('active'); 405 $('#list').find('#li_mr').insertBefore('li:eq(0)'); 406};407408// no - Norwegian409410NO = function () {411 localStorage.setItem('Language', 'no');412 $('#selectedlanguage').text(no);413 $('.listlanguages li a').removeClass('active');414 $('#bt_no').addClass('active');415 $('#list').find('#li_no').insertBefore('li:eq(0)'); 416};417418// fa - Persian419420FA = function () {421 localStorage.setItem('Language', 'fa');422 $('#selectedlanguage').text(fa);423 $('.listlanguages li a').removeClass('active');424 $('#bt_fa').addClass('active'); 425 $('#list').find('#li_fa').insertBefore('li:eq(0)'); 426};427428// pl - Polish429430PL = function () {431 localStorage.setItem('Language', 'pl');432 $('#selectedlanguage').text(pl);433 $('.listlanguages li a').removeClass('active');434 $('#bt_pl').addClass('active'); 435 $('#list').find('#li_pl').insertBefore('li:eq(0)'); 436};437438// pt_BR - Portuguese (Brazil)439440PT_BR = function () {441 localStorage.setItem('Language', 'pt_BR');442 $('#selectedlanguage').text(pt_BR);443 $('.listlanguages li a').removeClass('active');444 $('#bt_pt_BR').addClass('active'); 445 $('#list').find('#li_pt_BR').insertBefore('li:eq(0)'); 446};447448// pt_PT - Portuguese (Portugal)449450PT_PT = function () {451 localStorage.setItem('Language', 'pt_PT');452 $('#selectedlanguage').text(pt_PT);453 $('.listlanguages li a').removeClass('active');454 $('#bt_pt_PT').addClass('active'); 455 $('#list').find('#li_pt_PT').insertBefore('li:eq(0)'); 456};457458// ro - Romanian459460RO = function () {461 localStorage.setItem('Language', 'ro');462 $('#selectedlanguage').text(ro);463 $('.listlanguages li a').removeClass('active');464 $('#bt_ro').addClass('active'); 465 $('#list').find('#li_ro').insertBefore('li:eq(0)'); 466};467468// ru - Russian469470RU = function () {471 localStorage.setItem('Language', 'ru');472 $('#selectedlanguage').text(ru);473 $('.listlanguages li a').removeClass('active');474 $('#bt_ru').addClass('active'); 475 $('#list').find('#li_ru').insertBefore('li:eq(0)'); 476};477478479// sr - Serbian480481SR = function () {482 localStorage.setItem('Language', 'sr');483 $('#selectedlanguage').text(sr);484 $('.listlanguages li a').removeClass('active');485 $('#bt_sr').addClass('active'); 486 $('#list').find('#li_sr').insertBefore('li:eq(0)'); 487};488489// sv - Swedish490491SV = function () {492 localStorage.setItem('Language', 'sv');493 $('#selectedlanguage').text(sv);494 $('.listlanguages li a').removeClass('active');495 $('#bt_sv').addClass('active'); 496 $('#list').find('#li_sv').insertBefore('li:eq(0)'); 497};498499// th - Thai500501TH = function () {502 localStorage.setItem('Language', 'th');503 $('#selectedlanguage').text(th);504 $('.listlanguages li a').removeClass('active');505 $('#bt_th').addClass('active'); 506 $('#list').find('#li_th').insertBefore('li:eq(0)'); 507};508509// ta - Tamil510511TA = function () {512 localStorage.setItem('Language', 'ta');513 $('#selectedlanguage').text(ta);514 $('.listlanguages li a').removeClass('active');515 $('#bt_ta').addClass('active'); 516 $('#list').find('#li_ta').insertBefore('li:eq(0)'); 517};518519// te - Telugu520521TE = function () {522 localStorage.setItem('Language', 'te');523 $('#selectedlanguage').text(te);524 $('.listlanguages li a').removeClass('active');525 $('#bt_te').addClass('active'); 526 $('#list').find('#li_te').insertBefore('li:eq(0)'); 527};528529// tr - Turkish530531TR = function () {532 localStorage.setItem('Language', 'tr');533 $('#selectedlanguage').text(tr);534 $('.listlanguages li a').removeClass('active');535 $('#bt_tr').addClass('active'); 536 $('#list').find('#li_tr').insertBefore('li:eq(0)'); 537};538539// uk - Ukrainian540541UK = function () {542 localStorage.setItem('Language', 'uk');543 $('#selectedlanguage').text(uk);544 $('.listlanguages li a').removeClass('active');545 $('#bt_uk').addClass('active'); 546 $('#list').find('#li_uk').insertBefore('li:eq(0)'); 547};548549// vi - Vietnamese550551VI = function () {552 localStorage.setItem('Language', 'vi');553 $('#selectedlanguage').text(vi);554 $('.listlanguages li a').removeClass('active');555 $('#bt_vi').addClass('active'); 556 $('#list').find('#li_vi').insertBefore('li:eq(0)'); 557};558559560561// Button language 562563$("#bt_bg").click(function(){localStorage.setItem('Language', 'bg'); BG(); savelanguage();}); 564$("#bt_bn").click(function(){localStorage.setItem('Language', 'bn'); BN(); savelanguage();}); 565$("#bt_ca").click(function(){localStorage.setItem('Language', 'ca'); CA(); savelanguage();});566$("#bt_cs").click(function(){localStorage.setItem('Language', 'cs'); CS(); savelanguage();});567$("#bt_da").click(function(){localStorage.setItem('Language', 'da'); DA(); savelanguage();});568$("#bt_de").click(function(){localStorage.setItem('Language', 'de'); DE(); savelanguage();});569$("#bt_el").click(function(){localStorage.setItem('Language', 'el'); EL(); savelanguage();});570$("#bt_en_US").click(function(){localStorage.setItem('Language', 'en_US'); EN_US(); savelanguage();});571$("#bt_en_GB").click(function(){localStorage.setItem('Language', 'en_GB'); EN_GB(); savelanguage();});572$("#bt_es").click(function(){localStorage.setItem('Language', 'es'); ES(); savelanguage();});573$("#bt_et").click(function(){localStorage.setItem('Language', 'et'); ET(); savelanguage();});574$("#bt_fa").click(function(){localStorage.setItem('Language', 'fa'); FA(); savelanguage();});575$("#bt_fi").click(function(){localStorage.setItem('Language', 'fi'); FI(); savelanguage();});576$("#bt_fil").click(function(){localStorage.setItem('Language', 'fil'); FIL(); savelanguage();});577$("#bt_fr").click(function(){localStorage.setItem('Language', 'fr'); FR(); savelanguage();});578$("#bt_gu").click(function(){localStorage.setItem('Language', 'gu'); GU(); savelanguage();});579$("#bt_he").click(function(){localStorage.setItem('Language', 'he'); HE(); savelanguage();});580$("#bt_hi").click(function(){localStorage.setItem('Language', 'hi'); HI(); savelanguage();});581$("#bt_hr").click(function(){localStorage.setItem('Language', 'hr'); HR(); savelanguage();});582$("#bt_hu").click(function(){localStorage.setItem('Language', 'hu'); HU(); savelanguage();});583$("#bt_id").click(function(){localStorage.setItem('Language', 'id'); ID(); savelanguage();});584$("#bt_it").click(function(){localStorage.setItem('Language', 'it'); IT(); savelanguage();});585$("#bt_ja").click(function(){localStorage.setItem('Language', 'ja'); JA(); savelanguage();});586$("#bt_ko").click(function(){localStorage.setItem('Language', 'ko'); KO(); savelanguage();});587$("#bt_lt").click(function(){localStorage.setItem('Language', 'lt'); LT(); savelanguage();});588$("#bt_lv").click(function(){localStorage.setItem('Language', 'lv'); LV(); savelanguage();});589$("#bt_mr").click(function(){localStorage.setItem('Language', 'mr'); MR(); savelanguage();});590$("#bt_ms").click(function(){localStorage.setItem('Language', 'ms'); MS(); savelanguage();});591$("#bt_nl").click(function(){localStorage.setItem('Language', 'nl'); NL(); savelanguage();});592$("#bt_no").click(function(){localStorage.setItem('Language', 'no'); NO(); savelanguage();});593$("#bt_pl").click(function(){localStorage.setItem('Language', 'pl'); PL(); savelanguage();});594$("#bt_pt_BR").click(function(){localStorage.setItem('Language', 'pt_BR'); PT_BR(); savelanguage();});595$("#bt_pt_PT").click(function(){localStorage.setItem('Language', 'pt_PT'); PT_PT(); savelanguage();});596$("#bt_ro").click(function(){localStorage.setItem('Language', 'ro'); RO(); savelanguage();});597$("#bt_ru").click(function(){localStorage.setItem('Language', 'ru'); RU(); savelanguage();});598$("#bt_sk").click(function(){localStorage.setItem('Language', 'sk'); SK(); savelanguage();});599$("#bt_sl").click(function(){localStorage.setItem('Language', 'sl'); SL(); savelanguage();});600$("#bt_sr").click(function(){localStorage.setItem('Language', 'sr'); SR(); savelanguage();});601$("#bt_sv").click(function(){localStorage.setItem('Language', 'sv'); SV(); savelanguage();});602$("#bt_ta").click(function(){localStorage.setItem('Language', 'ta'); TA(); savelanguage();});603$("#bt_te").click(function(){localStorage.setItem('Language', 'te'); TE(); savelanguage();});604$("#bt_th").click(function(){localStorage.setItem('Language', 'th'); TH(); savelanguage();});605$("#bt_tr").click(function(){localStorage.setItem('Language', 'tr'); TR(); savelanguage();});606$("#bt_uk").click(function(){localStorage.setItem('Language', 'uk'); UK(); savelanguage();});607$("#bt_vi").click(function(){localStorage.setItem('Language', 'vi'); VI(); savelanguage();});608$("#bt_zh_CN").click(function(){localStorage.setItem('Language', 'zh_CN'); ZH_CN(); savelanguage();});609$("#bt_zh_TW").click(function(){localStorage.setItem('Language', 'zh_TW'); ZH_TW(); savelanguage();});610611612// Check localStorage613614if (localStorage.getItem('Language') == 'bg') { BG();}615if (localStorage.getItem('Language') == 'bn') { BN();}616if (localStorage.getItem('Language') == 'ca') { CA();}617if (localStorage.getItem('Language') == 'cs') { CS();}618if (localStorage.getItem('Language') == 'da') { DA();}619if (localStorage.getItem('Language') == 'de') { DE();}620if (localStorage.getItem('Language') == 'el') { EL();}621if (localStorage.getItem('Language') == 'en_US') { EN_US();}622if (localStorage.getItem('Language') == 'en_GB') { EN_GB();}623if (localStorage.getItem('Language') == 'es') { ES();}624if (localStorage.getItem('Language') == 'et') { ET();}625if (localStorage.getItem('Language') == 'fa') { FA();}626if (localStorage.getItem('Language') == 'fi') { FI();}627if (localStorage.getItem('Language') == 'fil') { FIL();}628if (localStorage.getItem('Language') == 'fr') { FR();}629if (localStorage.getItem('Language') == 'gu') { GU();}630if (localStorage.getItem('Language') == 'he') { HE();}631if (localStorage.getItem('Language') == 'hi') { HI();}632if (localStorage.getItem('Language') == 'hr') { HR();}633if (localStorage.getItem('Language') == 'hu') { HU();}634if (localStorage.getItem('Language') == 'id') { ID();}635if (localStorage.getItem('Language') == 'it') { IT();}636if (localStorage.getItem('Language') == 'ja') { JA();}637if (localStorage.getItem('Language') == 'ko') { KO();}638if (localStorage.getItem('Language') == 'lt') { LT();}639if (localStorage.getItem('Language') == 'lv') { LV();}640if (localStorage.getItem('Language') == 'mr') { MR();}641if (localStorage.getItem('Language') == 'ms') { MS();}642if (localStorage.getItem('Language') == 'nl') { NL();}643if (localStorage.getItem('Language') == 'no') { NO();}644if (localStorage.getItem('Language') == 'pl') { PL();}645if (localStorage.getItem('Language') == 'pt_BR') { PT_BR();}646if (localStorage.getItem('Language') == 'pt_PT') { PT_PT();}647if (localStorage.getItem('Language') == 'ro') { RO();}648if (localStorage.getItem('Language') == 'ru') { RU();}649if (localStorage.getItem('Language') == 'sk') { SK();}650if (localStorage.getItem('Language') == 'sl') { SL();}651if (localStorage.getItem('Language') == 'sr') { SR();}652if (localStorage.getItem('Language') == 'sv') { SV();}653if (localStorage.getItem('Language') == 'ta') { TA();}654if (localStorage.getItem('Language') == 'te') { TE();}655if (localStorage.getItem('Language') == 'th') { TH();}656if (localStorage.getItem('Language') == 'tr') { TR();}657if (localStorage.getItem('Language') == 'uk') { UK();}658if (localStorage.getItem('Language') == 'vi') { VI();}659if (localStorage.getItem('Language') == 'zh_CN') { ZH_CN();}660if (localStorage.getItem('Language') == 'zh_TW') { ZH_TW();}661662});
...
init.js
Source:init.js
1function start() {2 document.body.classList.add("match-braces");3 var listLanguages = ["html", "xml", "bash", "shell", "cpp", "css", "diff", "django", "dockerfile", "ruby", "go", "java", "javascript", "json", "less",4 "lisp", "lua", "makefile", "matlab", "nginx", "php", "powershell", "python", "r", "rust", "scss", "sql", "swift", "typescript", "vim", "xl"];5 var renderer = new marked.Renderer();6 function HTMLEncode(html) {7 var temp = document.createElement("div");8 (temp.textContent != null) ? (temp.textContent = html) : (temp.innerText = html);9 var output = temp.innerHTML;10 temp = null;11 return output;12 }13 renderer.code = function (code, language) {14 if (window.location.host == "blog.csdn.net") {15 return `<code class='language-${language}' style='overflow-x: visible !important;'>${HTMLEncode(code)}</code>`;16 } if (window.location.host == "gitee.com") {17 return `<code class='language-${language}' style='border: 0px !important;'>${HTMLEncode(code)}</code>`;18 }19 return `<code class='language-${language}'>${HTMLEncode(code)}</code>`;20 };21 init();22 initPre();23 initFile();24 function initFile() {25 switch (window.location.host) {26 case "github.com":27 var table = document.querySelector("table[class='highlight tab-size js-file-line-container']");28 githubTable(table);29 break;30 default:31 break;32 }33 }34 function githubTable(table) {35 if (!table) {36 return;37 }38 var language = [...table.parentNode.classList.values()].filter(function (val) { return val.indexOf("type-") > -1 });39 var text = table.innerText;40 if (language.length <= 0) {41 language = [hljs.highlightAuto(text, listLanguages).language];42 language = [(language == undefined ? "javascript" : language)];43 } else {44 language = [language[0].substring(5)];45 }46 var preElm = document.createElement("pre");47 preElm.setAttribute("data-download-link-label", "ä¸è½½ä»£ç ");48 addClass(preElm, ["pre", "line-numbers", "rainbow-braces", "no-brace-hover"]);49 console.log(marked("```" + language[0] + "\n" + text + "\n```", { renderer: renderer }))50 preElm.innerHTML = marked("```" + language[0] + "\n" + text + "\n```", { renderer: renderer });51 table.parentNode.replaceChild(preElm, table);52 }53 function initPre() {54 var pres = document.querySelectorAll("pre");55 switch (window.location.host) {56 case "gitee.com":57 giteePre(pres);58 break;59 case "git.beanjs.com":60 myPre(pres);61 break;62 case "blog.csdn.net":63 csdnPre(pres);64 break;65 case "github.com":66 githubPre(pres);67 break;68 case "www.npmjs.com":69 npmjsPre(pres);70 break;71 case "segmentfault.com":72 segmentfaultPre(pres);;73 break;74 default:75 break;76 }77 }78 function segmentfaultPre(pres){79 var links = document.querySelectorAll("link[rel='stylesheet']");80 for(var i = 0; i < links.length; i++){81 if(links[i].href.indexOf("css/vendors.css") != -1){82 links[i].remove();83 }84 }85 for (var i = 0; i < pres.length; i++) {86 pres[i].setAttribute("data-download-link-label", "ä¸è½½ä»£ç ");87 var codes = pres[i].querySelectorAll("code");88 var language = listLanguages.filter(function (val) { return getLan([...pres[i].classList.values()], val); });89 addClass(pres[i], ["pre", "line-numbers", "rainbow-braces", "no-brace-hover"]);90 if (codes.length <= 0) {91 var text = pres[i].innerText;92 if (language.length <= 0) {93 language = [hljs.highlightAuto(text, listLanguages).language];94 language = [(language == undefined ? "javascript" : language)];95 }96 pres[i].innerHTML = marked("```" + language[0] + "\n" + text + "\n```", { renderer: renderer });97 }else{98 for (var j = 0; j < codes.length; j++) {99 language = listLanguages.filter(function (val) { return getLan([...codes[j].classList.values()], val); });100 var text = codes[j].innerText;101 if (language.length <= 0) {102 language = [hljs.highlightAuto(text, listLanguages).language];103 language = [(language == undefined ? "javascript" : language)];104 }105 pres[i].innerHTML = marked("```" + language[0] + "\n" + text + "\n```", { renderer: renderer });106 }107 }108 }109 }110 function npmjsPre(pres){111 for (var i = 0; i < pres.length; i++) {112 pres[i].setAttribute("data-download-link-label", "ä¸è½½ä»£ç ");113 addClass(pres[i], ["pre", "line-numbers", "rainbow-braces", "no-brace-hover"]);114 var codes = pres[i].querySelectorAll("code");115 var preclassList = pres[i].classList;116 var language = listLanguages.filter(function (val) {117 return getLan([...preclassList.values()], val);118 });119 if (language.length <= 0) {120 language = listLanguages.filter(function (val) {121 return getLan([...pres[i].parentNode.classList.values()], val);122 });123 }124 if (codes.length <= 0) {125 var text = pres[i].innerText;126 if (language.length <= 0) {127 language = [hljs.highlightAuto(text, listLanguages).language];128 language = [(language == undefined ? "javascript" : language)];129 }130 pres[i].innerHTML = marked("```" + language[0] + "\n" + text + "\n```", { renderer: renderer });131 }132 }133 }134 function githubPre(pres) {135 for (var i = 0; i < pres.length; i++) {136 pres[i].setAttribute("data-download-link-label", "ä¸è½½ä»£ç ");137 addClass(pres[i], ["pre", "line-numbers", "rainbow-braces", "no-brace-hover"]);138 var codes = pres[i].querySelectorAll("code");139 var preclassList = pres[i].classList;140 var listClassName = preclassList.values();141 var language = [...listClassName].filter(function (val) { return listLanguages.indexOf(val) > -1 });142 if (language.length <= 0) {143 language = [...pres[i].parentNode.classList.values()].filter(function (val) { return val.indexOf("highlight-source") > -1 });144 }145 if (codes.length <= 0) {146 var text = pres[i].innerText;147 if (language.length <= 0) {148 language = [hljs.highlightAuto(text, listLanguages).language];149 language = [(language == undefined ? "javascript" : language)];150 } else {151 language = [language[0].substring(17)];152 }153 pres[i].innerHTML = marked("```" + language[0] + "\n" + text + "\n```", { renderer: renderer });154 }else{155 for (var j = 0; j < codes.length; j++) {156 var text = codes[j].innerText;157 if (language.length <= 0) {158 language = [hljs.highlightAuto(text, listLanguages).language];159 language = [(language == undefined ? "javascript" : language)];160 }161 pres[i].innerHTML = marked("```" + language[0] + "\n" + text + "\n```", { renderer: renderer });162 }163 }164 }165 }166 function giteePre(pres) {167 for (var i = 0; i < pres.length; i++) {168 pres[i].setAttribute("data-download-link-label", "ä¸è½½ä»£ç ");169 addClass(pres[i], ["pre", "line-numbers", "rainbow-braces", "no-brace-hover"])170 var codes = pres[i].querySelectorAll("code");171 var preclassList = pres[i].classList;172 var listClassName = preclassList.values();173 var language = [...listClassName].filter(function (val) { return listLanguages.indexOf(val) > -1 });174 if (codes.length <= 0) {175 var text = pres[i].innerText;176 if (language.length <= 0) {177 language = [hljs.highlightAuto(text, listLanguages).language];178 language = [(language == undefined ? "javascript" : language)];179 }180 pres[i].innerHTML = marked("```" + language[0] + "\n" + text + "\n```", { renderer: renderer });181 }182 }183 }184 function csdnPre(pres) {185 removeElm(document.querySelectorAll("div[data-title='å¤å¶']"));186 removeElm(document.querySelectorAll("pre ul[class='pre-numbering']"));187 for (var i = 0; i < pres.length; i++) {188 pres[i].setAttribute("data-download-link-label", "ä¸è½½ä»£ç ");189 addClass(pres[i], ["pre", "line-numbers", "rainbow-braces", "no-brace-hover"]);190 var codes = pres[i].querySelectorAll("code");191 var preclassList = pres[i].classList;192 if (codes.length <= 0) {193 var text = pres[i].innerText;194 var listClassName = preclassList.values();195 var language = [...listClassName].filter(function (val) { return listLanguages.indexOf(val) > -1 });196 if (language.length <= 0) {197 language = [hljs.highlightAuto(text, listLanguages).language];198 language = [(language == undefined ? "javascript" : language)];199 }200 pres[i].innerHTML = marked("```" + language[0] + "\n" + text + "\n```", { renderer: renderer });201 } else {202 var listClassName = preclassList.values();203 var language = [...listClassName].filter(function (val) { return listLanguages.indexOf(val) > -1 });204 for (var j = 0; j < codes.length; j++) {205 var text = codes[j].innerText;206 if (language.length <= 0) {207 var languageName = [...codes[j].classList.values()].filter(function (val) { return val.indexOf("language-") > -1 });208 if (languageName.length > 0) {209 language = [languageName[0].substring(9)];210 } else {211 language = [hljs.highlightAuto(text, listLanguages).language];212 language = [(language == undefined ? "javascript" : language)];213 }214 }215 pres[i].innerHTML = marked("```" + language[0] + "\n" + text + "\n```", { renderer: renderer });216 }217 }218 removeClass([pres[i]], ["pre", "line-numbers", "rainbow-braces", "no-brace-hover"]);219 removeAttr([pres[i]], "name");220 }221 }222 function myPre(pres) {223 for (var i = 0; i < pres.length; i++) {224 var codes = pres[i].querySelectorAll("code");225 for (var j = 0; j < codes.length; j++) {226 if (codes[j].className.indexOf("language-mermaid") != -1) {227 var htm = codes[j].innerHTML;228 var oldNode = codes[j].parentNode;229 var parentNode = oldNode.parentNode;230 var div = document.createElement('div');231 div.innerHTML = htm;232 div.classList.add("mermaid");233 parentNode.replaceChild(div, oldNode);234 } else {235 pres[i].setAttribute("data-download-link-label", "ä¸è½½ä»£ç ");236 addClass(pres[i], ["pre", "line-numbers", "rainbow-braces", "no-brace-hover"]);237 }238 initDiff(codes[j]);239 codes[j].classList.remove("hljs");240 }241 }242 }243 function removeClass(nodes, classs) {244 for (var i = 0; i < nodes.length; i++) {245 var listClassName = [...nodes[i].classList.values()];246 for (var j = 0; j < listClassName.length; j++) {247 if (classs.indexOf(listClassName[j]) == -1) {248 nodes[i].classList.remove(listClassName[j]);249 }250 }251 }252 }253 function initDiff(code) {254 if (code.className.indexOf("language-diff") != -1) {255 code.classList.add("diff-highlight");256 }257 }258 function addClass(node, listClass) {259 for (var i = 0; i < listClass.length; i++) {260 node.classList.add(listClass[i]);261 }262 }263 function removeElm(nodes) {264 for (var i = 0; i < nodes.length; i++) {265 nodes[i].remove();266 }267 }268 function removeAttr(nodes, attr) {269 for (var i = 0; i < nodes.length; i++) {270 var node = nodes[i];271 if (node.nodeType === 1) {272 nodes[i].removeAttribute(attr);273 }274 if (nodes[i].childNodes) {275 removeAttr(nodes[i].childNodes, attr);276 }277 }278 }279 function init() {280 var styles = document.querySelectorAll("link[rel='stylesheet']");281 for (var i = 0; i < styles.length; i++) {282 var href = styles[i].attributes["href"].nodeValue;283 if (href.indexOf("github.css") != -1) {284 styles[i].remove();285 break;286 }287 }288 }289 function getLan(listClass, val){290 if(val == "javascript"){291 return listClass.indexOf("js") > -1 || listClass.indexOf("javascript") > -1;292 }293 if(val == "shell"){294 return listClass.indexOf("sh") > -1 || listClass.indexOf("shell") > -1;295 }296 if(val == "go"){297 return listClass.indexOf("golang") > -1 || listClass.indexOf("go") > -1;298 }299 return listClass.indexOf(val) > -1;300 }...
custom.js
Source:custom.js
1$(document).ready(function() {2 var DrawChart = function() { 3 //Create horizontal bar chart using JQuery4 $('.chart').horizBarChart({selector: '.bar',speed: 3000});5 };6 var cleanup = function() {7 $('#searchbox #intro').empty();8 $('#searchbox #intro2').empty();9 $('#askgithub').empty();10 $('#result').empty();11 $('#progress').show();12 }13 14 //Handle submit15 $('#askgithub').submit(function() {16 $('#searchbox #intro').empty();17 $('#result').empty();18 $('#progress').show();19 });20 21 22 //Handle project intro23 if ($('#result').html().trim()) {24 $('#searchbox #intro').hide();25 }26 27 28 //Bind to hyperlinks 29 $('a.repositoryinfo').bind('click', cleanup);30 31 //Handle chart div32 $('.chart').horizBarChart({selector: '.bar',speed: 3000});33 34 //Find similar repositories on demand35 $('a#findsimilarrepos').bind('click', function() {36 ga('send', {37 'hitType': 'event', // Required.38 'eventCategory': 'similarrepos', // Required.39 'eventAction': $('input[name="reponame"]').val() // Required.40 });41 $("#wrapperfindsimilarrepos").empty();42 $("#wrapperfindsimilarrepos").html("finding similar repositories just for you <i class=\"fa fa-spinner fa-spin fa-1x\"></i>");43 var d2 = $.ajax({44 url : '/_findsimilarrepositories',45 dataType : 'json',46 timeout : (600000),47 data : {48 a : $('input[name="reponame"]').val()49 },50 success : function(data) {51 $("#similarrepos").html(data.similarrepos);52 $("#wrapperfindsimilarrepos").empty();53 },54 error : function(objAJAXRequest, strError) {55 $("#similarrepos").html("<span class=\"text-danger\">Query taking too long: Please try again latter</span>");56 $("#wrapperfindsimilarrepos").empty();57 }58 });59 $.when( d2 ).done(function(){60 $('a.repositoryinfo').bind('click',cleanup);61 });62 return false;63 });64 65 //Automatically display Horizontal Bar Charts66 if ($('#listlanguages').length > 0) {67 //Step1: Wait for the page to load! 68 $(window).bind("load", function() {69 $("#listlanguages").empty();$("#listlanguages").html("Lising languages <i class=\"fa fa-spinner fa-spin fa-1x\"></i>");70 //Step2: Function call using AJAX71 var d1 = $.ajax({url:'/_listlanguages',dataType:'json', timeout: (60000) ,data: {a: $('input[name="reponame"]').val()},72 success: function(data) {$("#listlanguages").empty();$("#listlanguages").html(data.languages);},73 error: function(objAJAXRequest, strError){$("#listlanguages").html("<span class=\"text-danger\">Query taking too long: Please try again latter</span>")} 74 });75 //Step3: Wait for AJAX to return, attach event handler to the new dynamic element76 $.when( d1 ).done(function(){77 $('#listlanguages').on('click',DrawChart);78 DrawChart(); //trigger a click event79 });80 });81 }82 ...
shift-select-language.js
Source:shift-select-language.js
1import React from 'react';2class ShiftSelectLanguage extends React.Component {3 4 constructor(props) {5 super(props);6 this.languages = AlphaPoint.config.languages ? AlphaPoint.config.languages.items : [];7 this.currentLanguage = localStorage.lang || AlphaPoint.config.defaultLanguage;8 this.types = {9 'dropdown': this.renderDropDown.bind(this),10 'list': this.renderList.bind(this),11 };12 this.defaultType = 'list';13 }14 changeLanguage(lan) {15 localStorage.lang = lan;16 window.location.reload();17 }18 renderDropDown() {19 const listLanguages = this.languages.map((item, index) => (20 <a className="dropdown-item" onClick={() => this.changeLanguage(item.value)}>{item.name}</a>21 ));22 let currentLunguage = this.languages.filter(lang => lang.value === this.currentLanguage)[0];23 return (24 <div className="dropdown">25 <button className="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">26 {currentLunguage.name}27 </button>28 <div className="dropdown-menu" aria-labelledby="dropdownMenuButton">29 {listLanguages}30 </div>31 </div>32 );33 }34 renderList() {35 const listLanguages = this.languages.map((item, index) => {36 let itemClasses = 'language-item';37 if (item.value === localStorage.lang) {38 itemClasses += ' active';39 }40 return (41 <li className={itemClasses} key={index}>42 <a className="language-link" onClick={() => this.changeLanguage(item.value)}>{item.name}</a>43 </li>44 );45 });46 return (47 <ul className="language-lists">48 {listLanguages}49 </ul>50 );51 }52 render() {53 let listLanguages = '';54 const type = this.props.type;55 if (this.types[type]) {56 listLanguages = this.types[type]();57 } else {58 listLanguages = this.types[this.defaultType]();59 }60 return (61 <div className="languages-section">62 {listLanguages}63 </div>64 );65 }66}...
Main.js
Source:Main.js
1import React, { Component } from "react";2import Home from "./Home";3import Background from "./Background";4function Page(props) {5 return (6 <div>7 <Home repos={props.repos} languages={props.languages} />8 <Background />9 </div>10 );11}12class Main extends Component {13 constructor(props) {14 super(props);15 this.state = {16 repos: null,17 listLanguages: null,18 };19 }20 getReposGit() {21 return fetch(22 "https://api.github.com/users/emajidev/repos"23 ).then((response) => response.json());24 }25 getLanguages(repos) {26 let listLanguages = [];27 var xmlHttp = new XMLHttpRequest();28 repos.map((item) => {29 xmlHttp.open("GET", item.languages_url, false); // false for synchronous request30 xmlHttp.send(null);31 let response = JSON.parse(xmlHttp.response);32 let array = Object.keys(response);33 listLanguages.push(array);34 });35 return listLanguages;36 }37 async componentDidMount() {38 let getRepos = await this.getReposGit();39 let getLanguages = await this.getLanguages(getRepos);40 this.setState({ repos: getRepos, listLanguages: getLanguages });41 }42 render() {43 return (44 <div className="Main">45 {this.state.repos != null && this.state.listLanguages ? (46 <Page repos={this.state.repos} languages={this.state.listLanguages} />47 ) : (48 <div>49 <h1 style={{ color: "black" }}>CARGANDO</h1>50 </div>51 )}52 </div>53 );54 }55}...
Header.js
Source:Header.js
1import React, {useRef, useEffect, useState} from 'react'2import Component from '../components/Header/Header'3function Header(props) {4 const globalWrapperRef = useRef(null);5 const [GlobalWrapperWidht, setGlobalWrapperWidht] = useState(0);6 const ListLanguages = getListLanguages(props.languageID, props.setLanguageID);7 useEffect(() => {8 setGlobalWrapperWidht(globalWrapperRef.current.clientWidth);9 }, [])10 11 return <Component 12 {...props}13 GlobalWrapperWidht={GlobalWrapperWidht}14 ListLanguages={ListLanguages}15 globalWrapperRef={globalWrapperRef}16 />17}18export default Header;19function getListLanguages(languageID, setLanguageID) {20 const activeLanguageID = languageID ? languageID : "ukr";21 const listLanguages = [22 {23 id: "ukr",24 name: "УкÑаÑнÑÑка"25 },26 {27 id: "rus",28 name: "Ð ÑÑÑкий"29 }30 ];31 32 if (listLanguages.length) {33 return (34 <ul className="listLanguages">35 {listLanguages.map(({id, name}) => {36 let classStyle = "";37 let text = name;38 if (activeLanguageID === id) {39 classStyle = "active";40 text = `${name} /`;41 }42 return (43 <li className={classStyle} key={id}>44 <span onClick={() => {45 setLanguageID(id)46 }}>47 {text}48 </span>49 </li>50 );51 })}52 </ul>53 )54 } else {55 return '';56 }...
plugins.js
Source:plugins.js
1/*global $,console, alert*/234$(function () {5 6 7 "use strict";8 9 /****** Append *****/10 11 $('.btnAppend').click(function () {12 13 $('.listLanguages').append("<li>" + $('.inputAppend').val() + "</li>");14 15 });1617 /****** AppendTo *****/18 19 $('.btnAppendTo').click(function () {20 21 $("<li>" + $('.inputAppendTo').val() + "</li>").appendTo($('.listLanguages'));22 23 });24 25 /****** Prepend *****/26 27 $('.btnPrepend').click(function () {28 29 $('.listLanguages').prepend("<li>" + $('.inputPrepend').val() + "</li>");30 31 });32 33 /****** PrependTo *****/34 35 $('.btnPrependTo').click(function () {36 37 $("<li>" + $('.inputPrependTo').val() + "</li>").prependTo($('.listLanguages'));38 39 });40 41 /****** Before *****/42 43 $('.btnBefore').click(function () {44 45 $('.listLanguages').before("<p>" + $('.inputBefore').val() + "</p>");46 47 });48 49 /****** After *****/50 51 $('.btnAfter').click(function () {52 53 $('.listLanguages').after("<p>" + $('.inputAfter').val() + "</p>");54 55 });56
...
highlight-loader.js
Source:highlight-loader.js
...13 var load = function(){14 hljs.highlightBlock(block);15 };16 if(lang){17 if(hljs.listLanguages().indexOf(lang)===-118 &&listLanguages.indexOf(lang)===-1){19 listLanguages.push(lang);20 $.get('plugins/highlightjs/languages/'+lang+'.js',function(func){21 eval('hljs.registerLanguage(lang,'+func+');');22 load();23 },'text');24 }25 else{26 if(hljs.listLanguages().indexOf(lang)===-1){27 var retry = function(){28 if(hljs.listLanguages().indexOf(lang)===-1){29 setTimeout(retry,1000);30 }31 else{32 load();33 }34 };35 setTimeout(retry,1000);36 }37 else{38 load();39 }40 }41 }42 });...
Using AI Code Generation
1const playwright = require('playwright');2(async () => {3 for (const browserType of ['chromium', 'webkit', 'firefox']) {4 const browser = await playwright[browserType].launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const languages = await page.context().languages();8 console.log(languages);9 await browser.close();10 }11})();12const playwright = require('playwright');13(async () => {14 for (const browserType of ['chromium', 'webkit', 'firefox']) {15 const browser = await playwright[browserType].launch();16 const context = await browser.newContext({17 geolocation: { longitude: 12.492507, latitude: 41.889938 },18 });19 const page = await context.newPage();20 const languages = await page.context().languages();21 console.log(languages);22 await browser.close();23 }24})();25const playwright = require('playwright');26(async () => {27 for (const browserType of ['chromium', 'webkit', 'firefox']) {28 const browser = await playwright[browserType].launch();29 const context = await browser.newContext({30 geolocation: { longitude: 12.492507, latitude: 41.889938 },31 });32 const page = await context.newPage();33 await page.waitForTimeout(2000);34 await browser.close();35 }36})();37const playwright = require('playwright');38(async () => {39 for (const browserType of ['chromium', 'webkit', 'firefox']) {40 const browser = await playwright[browserType].launch();41 const context = await browser.newContext({42 geolocation: { longitude: 12.492507, latitude: 41.889938 },
Using AI Code Generation
1const { chromium, webkit, firefox } = require('playwright');2(async () => {3 for (const browserType of [chromium, webkit, firefox]) {4 const browser = await browserType.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const languages = await page.context().languages();8 console.log(languages);9 await browser.close();10 }11})();
Using AI Code Generation
1const playwright = require('playwright');2(async () => {3 const browser = await playwright['chromium'].launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const languages = await page.context().languages();7 console.log(languages);8 await browser.close();9})();10### **`page.context().permissions()`**11const playwright = require('playwright');12(async () => {13 const browser = await playwright['chromium'].launch();14 const context = await browser.newContext();15 const page = await context.newPage();16 const permissions = await page.context().permissions();17 console.log(permissions);18 await browser.close();19})();20### **`page.context().overridePermissions(origin, permissions)`**21const playwright = require('playwright');22(async () => {23 const browser = await playwright['chromium'].launch();24 const context = await browser.newContext();25 const page = await context.newPage();26 await page.click('text=Ask for Geolocation');27 await page.waitForSelector('text=Position unavailable');28 await browser.close();29})();30### **`page.context().clearPermissions()`**31const playwright = require('playwright');32(async () => {33 const browser = await playwright['chromium'].launch();
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const languages = await page.context().languages();7 console.log(languages);8 await browser.close();9})();10## browserType.launchServer([options])
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const languages = await page.context().languages();7 console.log(languages);8 await browser.close();9})();10const { chromium } = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const context = await browser.newContext();14 const page = await context.newPage();15 const languages = await page.context().languages();16 console.log(languages);17 await browser.close();18})();19const { chromium } = require('playwright');20(async () => {21 const browser = await chromium.launch();22 const context = await browser.newContext({23 extraHTTPHeaders: {
Using AI Code Generation
1const playwright = require('playwright');2const fs = require('fs');3(async () => {4 for (const browserType of ['chromium', 'firefox', 'webkit']) {5 const browser = await playwright[browserType].launch();6 const context = await browser.newContext();7 const page = await context.newPage();8 const languages = await page.evaluate(() => window.playwright.listLanguages());9 fs.writeFileSync(`${browserType}.json`, JSON.stringify(languages, null, 2));10 await browser.close();11 }12})();13 {14 },15 {16 },17 {18 },19 {20 },21 {22 },23 {24 },25 {
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const page = await browser.newPage();5 const languages = await page._client.send('Emulation.getAcceptedLanguages');6 console.log(languages);7 await browser.close();8})();
Using AI Code Generation
1const { chromium } = require('playwright');2const { listLanguages } = require('playwright-core/lib/server/supplements/recorder/recorderSupplement.js');3(async () => {4 const browser = await chromium.launch({ headless: false });5 const context = await browser.newContext();6 const page = await context.newPage();7 const languages = await listLanguages();8 console.log(languages);9 await page.screenshot({ path: `example.png` });10 await browser.close();11})();
Using AI Code Generation
1const { chromium } = require('playwright-chromium');2const { devices } = require('playwright-chromium');3const iPhone = devices['iPhone 11 Pro Max'];4const { webkit } = require('playwright-webkit');5const { firefox } = require('playwright-firefox');6(async () => {7 const browser = await chromium.launch({8 });9 const context = await browser.newContext();10 const page = await context.newPage();11 const languages = await page._client.send('Playwright.listLanguages');12 console.log(languages);13 await browser.close();14})();
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!