PageSourceSearch

https://www.lfs-bw.de/_assets/d40451cc70f442d68f3d6e50be4692de/Lib…/js/bitbw-common.inject-style.js?1782218941

js lfs-bw.de collected 2026-10-02 10:35:08 UTC 3,818 bytes, 102 lines download raw bytes

1//łśćąęźż
2
3var Bitbw = Bitbw || {};
4Bitbw.Common = Bitbw.Common || {};
5
6
7/* ================================================================================================================== */
8/* ============================================== Common [START] ==================================================== */
9/* ================================================================================================================== */
10/* ============================================== bitbwInjectStyle [START] ========================================== */
11Bitbw.Common.bitbwInjectStyle = function(){
12    let funcName='bitbwInjectStyle';
13
14    let info = {
15        registerName:'register-bitbwInjectStyle',
16        attrRegistered: 'data-bitbw-inject-style-registered',
17        attrInjectStyle: 'data-bitbw-inject-style',
18        attrInjectStyleDone: 'data-bitbw-inject-style-done',
19        attrStyle: 'style',
20    };
21
22    let helperInitInjectStyleOnElement = function(objElement){
23        if(typeof(objElement) !== "object" || objElement === null){
24            return false;
25        }
26
27        if(typeof(objElement.getAttribute) !== 'function'){
28            return false;
29        }
30
31        let attrInjectStyle = objElement.getAttribute(info.attrInjectStyle);
32        if(typeof(attrInjectStyle) !== "string" || attrInjectStyle.trim().length === 0){
33            return false;
34        }
35
36        let attrOrigStyle = objElement.getAttribute(info.attrStyle);
37
38        if(typeof(attrOrigStyle) === "string" && attrInjectStyle.trim().length >= 0){
39            attrOrigStyle = attrInjectStyle.trim();
40        }else{
41            attrOrigStyle = '';
42        }
43
44        objElement.style = attrOrigStyle + ' ' + attrInjectStyle;
45        objElement.removeAttribute(info.attrInjectStyle);
46        objElement.setAttribute(info.attrInjectStyleDone, '1');
47        return true;
48    }
49
50    let helperInit = function(){
51        let elementList = document.querySelectorAll('['+info.attrInjectStyle+']');
52
53        if(elementList === null || elementList.length === 0){
54            return;
55        }
56
57        for(let i=0; i<elementList.length; i++){
58            helperInitInjectStyleOnElement(elementList[i]);
59        }
60    }
61
62    let helperRegisterWatcher = function(){
63        let objWatcher = document.querySelector('body');
64
65        let attrRegistered = objWatcher.getAttribute(info.attrRegistered);
66        if(attrRegistered === '1'){
67            return;
68        }
69
70        objWatcher.setAttribute(info.attrRegistered, '1');
71
72        // Use MutationObserver
73        if (window.MutationObserver) {
74            const observer = new MutationObserver((mutations) => {
75                mutations.forEach((mutation) => {
76                    // Check new nodes
77                    mutation.addedNodes.forEach((node) => {
78                        helperInitInjectStyleOnElement(node);
79                    });
80                });
81            });
82
83            observer.observe(document.body, {
84                childList: true,
85                subtree: true,
86            });
87        }
88        // Fallback for older browsers
89        else {
90            document.addEventListener('DOMNodeInserted', function (event) {
91                helperInitInjectStyleOnElement(event.target);
92            });
93        }
94    }
95
96    helperRegisterWatcher();
97    helperInit();
98}
99/* ============================================== bitbwInjectStyle [END] ============================================ */
100/* ================================================================================================================== */
101/* ============================================== Common [END] ====================================================== */
102/* ================================================================================================================== */

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.