document.addEventListener("DOMContentLoaded", function(event) {
    const unityPageIds = [/* Unity blocks */ 257602419, 257602424, 257602428,
                          257602433,257602436,257602439,257602444,257602448,257602451,257602455,257602458,
                          257602462,257602466,257602469,257602473,257602477,257602480,257602485,257602489,
                          257602545,257602550,257602554,
                         /*Unity C#*/213206620,213206624,213206625,
                         212237472,212237473,212237474,212237475,212237476,212237477,212237478,212237479,
                         213117638,213117639,213117640,213117641,213117642,213117643,213117644,213117645,
                         225823400,225827096,225827817,225935297,225937018,225937102,226238510,226238519,
                         227245552,227245553,227245554,227245555,227245556,227245557,227245559,227245560,
                         /*metodica*/215339199,227979954,230452892,230452267,242503495,
                         /*демо*/267997590,267997591,267997592,265642032,265642046,265642052,215012807,215012808,215012809,
                          279601174,279601237,279601242];
    const cospacesPageIds = [/* Cospaces */ 147731166,147434264,147434266,
                             147434279,147434281,147434282,147434285,147434900,147434903,147434905,147434909,
                             145468734,145468735,145468736,145468737,145468738,145468739,145468740,145468741,
                             145482248,145482249,145482250,145482251,145482252,145482253,145482254,145482255,
                             146285631,146285632,146285633,146285634,146285635,146285636,146285637,146285638,
                             150233456,171663777,230441802,230441817,244864049,
                            /*демо*/279226328,279226356,279226360];
    const mcPageIds = [/* Minecraft */ 16132142,19729465,99986392,99987329,
                       47171611,100990590,47171612,47171618,93403051,47171621,47171622,47171610,47171608,
                       111441420,111441421,111441422,111441423,111441424,111441425,111441426,111441427,
                       18800284,18800285,18800286,18800287,18800288,18800289,18800290,18800291,
                       37957911,37957912,37957913,37957914,37957915,37957916,37957917,37957918,
                       99855557,99855556,228559049,228559048,244826055,
                       /*junior*/42139901,147752839,147752844,147752846,147752850,147752851,147752857,147752859,
                      147752863,147752865,147752866,147752869,144591743,144591744,144591745,144591746,144591747,
                       144591748,144591749,144591750,/*део*/279343282,279343303,279343308,279343315,
                      /*marathon*/172030451,172030454,172030456,172030459,172030462,172030466,172030468,172030471,
                      /*demo*/279138680,279138779,279139038,279139224];
    const robloxPageIds = [/* Roblox */ 110232282,110232286,110232289,
                           110236974,110285148,110984206,110985105,111021623,111363384,111363668,111433853,
                           114177456,114453048,114453328,115213322,115218066,115290551,115290868,115471096,,
                           116309528,116309529,116309530,116309531,116309532,116309533,116309534,116309535,
                           121195331,121195332,121253723,121393765,121393736,121393767,122104941,122107792,
                           105992991,131659511,228691319,228691723,244874328,
                          /*демо*/279167009,279167190,279167198];
    const giftPageIds = [/* Подарки */ 274701231,274701232,274701234,275259890,279623109,276573329,276573704,
                         277937799,277937801,277937802,277937803,277937804,277937806,
                         277937808,277937809,277937810,277937811,277937812,277937813,277937814,
                        /*Scratch*/277937800,279139725,279139779];
    const scratchPageIds = [/* scratch 3 б. п. */ 155627987, 155627989, 155627991, 155627996,
                            149486080, 149486190, 149486315, 149486447, 149486766, 149871662, 150422088, 151523140,
                            154707608, 154707609, 154707610, 154707611, 154707612, 154707613, 154707614, 154707615,
                            173543100, 173543101, 173543102, 174520284, 174520289, 174520326, 174520332, 174520336,
                            174812058, 174812059, 174812061, 174812061, 174812062, 174812063, 174812064, 174812065,
                            175290861, 180230468, 231164630, 231323565, 244864005,
                            /*demo*/198293873,198293874,198293875,198293876,
                            /* scratch jr. */ 51226108,51372703,87855033,
                            53451835,54134690,54046576,54046841,54135021,54135414,54136228,54136413,
                            65820959,65820960,65820961,65820962,65820963,65820964,65820965,65820967,
                            84140341,84140342,84140343,84140344,84140345,84140346,84140347,84140348,
                            84329418,84329433,84329441,84329450,84329457,84329465,84329475,84329486,
                            231909601,244827272,83808658,231909736,76197988,
                            /*demo*/198293857,198293858,198293859,
                            /* scratch level 1 */ 239480758,239480759,239480760,239480761,
                            239485116,239486552,239487972,239501284,239502992,239503481,239503570,239503664,
                            239682606,239683315,239683650,239683820,239684122,239692474,239693567,239694177,
                            239738357,239771186,239776890,239777023,239777433,239777715,239778110,239778640,
                            239811859,239812214,239820981,239821181,239841396,239841487,239841577,239895320,
                            254423522,255457592,254421699,255456909,/*demo*/279166919,279166920,279166921,279166925,
                            /* scratch math */ 245043212,245043214,245043497,245043516,,245043710,245044075,
                            245044082,245044090,245044112,245044120,245044206,245044222,245044234,245044335,
                            245044346,245044399,245171023,245171135,245171419,245171463,245171507,245171565,
                            245171601,245171737,245171788,245172212,245172266,245174282,245175483,245176094,
                            245176179,245176185,245176193,245176200,245176257,245177922,245220297,245222904,
                            245226469,245228285,245228581,245228725,245228761,245228795,245228820,245228865,
                            245228957,245229098,245229385,245229426,
                            /*demo*/279166676,279166697,279166701,279166707,
                           /* scratch 2 */ 257767087,257767089,257767101,257767109,
                            257767042,257767043,257767044,257767045,257767046,257767047,257767048,257767049,
                            257767050,257767051,257767052,257767053,257767054,257767055,257767056,257767057,
                            257767058,257767059,257767060,257767061,257767062,257767063,257767064,257767065,
                            257767066,257767067,257767068,257767069,257767070,257767071,257767072,257767073,
                            257767074,257767075,257767076,257767077,/*demo*/279166796,279166799,279166801,279166805,
                           /* marathon */ 172034374,172034377,172034379,172034380,172034382,172034384,172034386,172034389,
                           /* marathon+paint */204034318,172032683,172032686,172032688,172032690,172032693,
                            172032696,172032698,172032701,
                           /*scratch deмo*/198293869,198293870,198293871,198293872];

    const pageUrl = window.location.href;
    if (pageUrl.includes("/pl/teach/control/lesson/view?id=")) {
        const lessonClassicCss = "/pl/layout/23721/8/lesson-classic.css";
        let lessonCss = lessonClassicCss;
        const pageId = parseInt(pageUrl.split("?id=")[1]);

        if (scratchPageIds.includes(pageId)) {
            lessonCss = "/pl/layout/23721/16/lesson-scratch.css";
        } else if (unityPageIds.includes(pageId)) {
            lessonCss = "/pl/layout/23721/19/lesson-unity.css";
        } else if (cospacesPageIds.includes(pageId)) {
            lessonCss = "/pl/layout/23721/20/lesson-cospaces.css";
        } else if (mcPageIds.includes(pageId)) {
            lessonCss = "/pl/layout/23721/17/lesson-mc.css";
        } else if (robloxPageIds.includes(pageId)) {
            lessonCss = "/pl/layout/23721/18/lesson-roblox.css";
        } else if (giftPageIds.includes(pageId)) {
            lessonCss = "/pl/layout/23721/23/lesson-podarki.css";
        }

        const mainCss = "/pl/layout/23721/3/main.css";
        const lessonJs = "/pl/layout/23721/9/lesson.js";

        const head = document.querySelector("head");
        head.insertAdjacentHTML("beforeend", `<link href="${mainCss}" rel="stylesheet">`);
        head.insertAdjacentHTML("beforeend", `<link href="${lessonCss}" rel="stylesheet">`);
        head.insertAdjacentHTML("beforeend", `<script src="${lessonJs}"></script>`);
    }
});
