PageSourceSearch

https://www.die-stiftung.de/wp-content/themes/diestiftung/js/borlabs-cookie/borlabs-cookie-custom.js?ver=1.0.0

js die-stiftung.de collected 2026-10-02 07:53:06 UTC 4,827 bytes, 162 lines download raw bytes

1jQuery(document).ready(function ($) {
2	function onBannerVisible(callback) {
3		var observer = new MutationObserver(function (mutations, obs) {
4			var $banner = $('#BorlabsCookieBox .brlbs-cmpnt-dialog div[role="document"]');
5			if ($banner.length && $banner.css('display') !== 'none') {
6				obs.disconnect();
7				callback();
8			}
9		});
10		observer.observe(document.body, { childList: true, subtree: true });
11	}
12
13	function waitForElement(selector, maxRetries, interval) {
14		maxRetries = maxRetries || 20;
15		interval = interval || 200;
16		return new Promise(function (resolve, reject) {
17			var retries = 0;
18			(function check() {
19				var $el = $(selector);
20				if ($el.length) {
21					resolve($el);
22				} else if (retries++ >= maxRetries) {
23					reject('Element "' + selector + '" nicht gefunden.');
24				} else {
25					setTimeout(check, interval);
26				}
27			})();
28		});
29	}
30
31	// === HIDE COOKIE WIDGET ===
32	(function hideCookieWidget() {
33		var attrObserver = null;
34
35		function hide() {
36			var widget = document.getElementById('BorlabsCookieWidget');
37			if (!widget) return;
38
39			if (widget.style.getPropertyValue('display') !== 'none') {
40				widget.style.setProperty('display', 'none', 'important');
41			}
42
43			if (!attrObserver) {
44				attrObserver = new MutationObserver(hide);
45				attrObserver.observe(widget, {
46					attributes: true,
47					attributeFilter: ['style', 'class']
48				});
49			}
50		}
51
52		hide();
53
54		new MutationObserver(hide).observe(document.body, {
55			childList: true,
56			subtree: true
57		});
58	})();
59
60	onBannerVisible(function () {
61		waitForElement('.brlbs-cmpnt-dialog').then(function () {
62
63			// === REPLACE BUTTON (brlbs-btn-accept-all) ===
64			var $oldBtnContainer = $('.brlbs-cmpnt-pur-btn.accept-all');
65			var $oldBtn = $oldBtnContainer.find('button.brlbs-btn-accept-all');
66			var $newBtn = $('button.brlbs-cmpnt-btn.brlbs-btn-accept-all');
67
68			if ($oldBtn.length && $newBtn.length) {
69				$oldBtn.remove();
70				$oldBtnContainer.append($newBtn);
71			}
72
73			// === REMOVE UNUSED TEXT AND FORM (brlbs-text-sm / form) ===
74			var $container = $('.brlbs-cmpnt-dialog-entrance-description').first();
75
76			if ($container.length) {
77				var $all = $container.find('.brlbs-text-sm');
78				var $keep = $all.filter(function (_, el) {
79					return $(el).find('.brlbs-cmpnt-pur').length > 0;
80				}).first();
81
82				if ($keep.length) {
83					$all.each(function () {
84						if (this !== $keep[0] && !$.contains(this, $keep[0])) {
85							$(this).remove();
86						}
87					});
88				}
89
90				$container.closest('.brlbs-cmpnt-dialog-iab-tcf-description').find('form').remove();
91			}
92
93			// === REMOVE PREFERENCES ===
94			var $prefBtn = $('button.brlbs-cmpnt-btn-preferences');
95
96			if ($prefBtn.length) {
97				var $wrapper = $prefBtn.closest('.overflow-auto, [class*="brlbs-space-y"]');
98
99				if (!$wrapper.length) {
100					$wrapper = $prefBtn.parents().filter(function (_, el) {
101						var $el = $(el);
102						return $el.find('button').length === 1 && $el.text().trim() === $prefBtn.text().trim();
103					}).first();
104				}
105
106				if ($wrapper.length) {
107					$wrapper.remove();
108				} else {
109					$prefBtn.closest('div').remove();
110				}
111			}
112
113			// === REMOVE BRANDING TEXT AND SVG ===
114			var $brandingLink = $('.brlbs-cmpnt-support-branding-link');
115
116			if ($brandingLink.length) {
117				var $brandingText = $brandingLink.find('span');
118				var $brandingSvg = $brandingLink.find('svg');
119
120				if ($brandingText.length) {
121					var updatedText = $brandingText.text().replace(/^powered by Borlabs Cookie -\s*/i, '');
122					$brandingText.text(updatedText);
123				}
124
125				$brandingSvg.remove();
126			}
127
128			// === ADD ACCESSIBILITY BUTTON ===
129			var $privacyLink = $('.brlbs-cmpnt-privacy-link');
130			if ($privacyLink.length && !$('.brlbs-cmpnt-accessibility-link').length) {
131				var accessibilityLink = $('<a>', {
132					href: 'https://www.faz-bm.de/erklaerung-zur-barrierefreiheit/',
133					class: 'brlbs-cmpnt-link brlbs-cmpnt-accessibility-link',
134					target: '_blank',
135					text: 'Barrierefreiheit'
136				});
137				$privacyLink.after(accessibilityLink);
138			}
139
140			// === REPLACE [fbm_current_url] WITH CURRENT URL (URL-encoded) ===
141			var encodedUrl = encodeURIComponent(window.location.href);
142			var root = document.getElementById('BorlabsCookieBox');
143			var walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, null, false);
144			var textNode;
145
146			while ((textNode = walker.nextNode())) {
147				if (textNode.nodeValue.indexOf('[fbm_current_url]') !== -1) {
148					textNode.nodeValue = textNode.nodeValue.replace(/\[fbm_current_url\]/g, encodedUrl);
149				}
150			}
151
152			$('#BorlabsCookieBox').find('*').each(function (_, el) {
153				$.each(el.attributes, function (_, attr) {
154					if (attr.specified && attr.value.indexOf('[fbm_current_url]') !== -1) {
155						$(el).attr(attr.name, attr.value.replace(/\[fbm_current_url\]/g, encodedUrl));
156					}
157				});
158			});
159
160		}).catch(console.warn);
161	});
162});

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.