1const sponsoredSection = { 2 display(config) { 3 // Walidacja parametrów wejÅciowych 4 if (!config || typeof config !== "object") { 5 console.error("Brak konfiguracji lub nieprawidÅowy format"); 6 return false; 7 } 8 9 const { sectionSelector, titleWrapperText, logoSrc, logoAlt, logoHref } = 10 config; 11 12 // Sprawdzenie czy wymagane parametry zostaÅy przekazane 13 if (!sectionSelector || !titleWrapperText || !logoSrc || !logoHref) { 14 console.error("Brak wymaganych parametrów konfiguracyjnych"); 15 return false; 16 } 17 18 const section = document.querySelector(sectionSelector); 19 if (!section) { 20 console.warn( 21 `Element o selektorze "${sectionSelector}" nie zostaÅ znaleziony`, 22 ); 23 return false; 24 } 25 26 try { 27 const wrapper = this.getWrapper({ 28 titleWrapperText, 29 logoSrc, 30 logoAlt: logoAlt || "Logo sponsora", // DomyÅlna wartoÅÄ dla alt 31 logoHref, 32 }); 33 section.parentNode.insertBefore(wrapper, section.nextSibling || null); 34 return true; 35 } catch (error) { 36 console.error( 37 "WystÄ piÅ bÅÄ d podczas tworzenia sekcji sponsorowanej:", 38 error, 39 ); 40 return false; 41 } 42 }, 43 44 getWrapper({ titleWrapperText, logoSrc, logoAlt, logoHref }) { 45 const CSS_CLASSES = { 46 wrapper: "sponsored-placement-wrapper", 47 titleWrapper: "sponsored-placement-title-wrapper", 48 logo: "sponsored-placement-logo", 49 logoLink: "sponsored-placement-logo-link", 50 }; 51 52 const titleWrapper = document.createElement("div"); 53 titleWrapper.classList.add(CSS_CLASSES.titleWrapper); 54 titleWrapper.innerHTML = titleWrapperText; 55 56 const logoElement = document.createElement("img"); 57 logoElement.src = logoSrc; 58 logoElement.classList.add(CSS_CLASSES.logo); 59 logoElement.alt = logoAlt; 60 61 const logoLink = document.createElement("a"); 62 logoLink.classList.add(CSS_CLASSES.logoLink); 63 logoLink.href = logoHref; 64 logoLink.rel = "nofollow"; 65 logoLink.target = "_blank"; 66 logoLink.appendChild(logoElement); 67 68 const wrapper = document.createElement("div"); 69 wrapper.classList.add(CSS_CLASSES.wrapper); 70 wrapper.appendChild(titleWrapper); 71 wrapper.appendChild(logoLink); 72 73 return wrapper; 74 }, 75}; 76 77// Przyklad wywolania 78// 79// sponsoredSection.display({ 80// sectionSelector: ".month-topic .section__title", 81// titleWrapperText: "Sponsor Tematu MiesiÄ ca", 82// logoSrc: "https://cdn.files.smcloud.net/t/Logo_Novo_Nordisk.png", 83// logoAlt: "Novo Nordisk.", 84// logoHref: "https://ootylosci.pl/ " 85// });
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.