1window.addEventListener('DOMContentLoaded', () => { 2 // ------------------------------------------------------------ 3 // 1. ÐбÑие вÑпомогаÑелÑнÑе ÑÑнкÑии и пÑовеÑки 4 // ------------------------------------------------------------ 5 6 // ЧÑÑнÑй ÑпиÑок ÑÑÑаниÑ, где Ð¿Ð¾Ð»Ñ Ð½Ðµ Ð´Ð¾Ð»Ð¶Ð½Ñ Ð´Ð¾Ð±Ð°Ð²Ð»ÑÑÑÑÑ/заполнÑÑÑÑÑ 7 const blacklist = [ 8 '/sales/control/', '/control/', '/admin/', 9 '/user/control/user/update', '/pl/sales/deal', '/sales/control/deal/update', 10 '/deal/update/', '/deal/view/', '/order/edit/', '/order/view/' 11 ]; 12 if (blacklist.some(path => window.location.pathname.includes(path))) return; 13 14 // ÐÑовеÑка, ÑвлÑеÑÑÑ Ð»Ð¸ ÑоÑма ÑоÑмой заказа (ÑодеÑÐ¶Ð¸Ñ Ð¿Ð¾Ð»Ñ dealCustomFields) 15 function isOrderForm(form) { 16 return !!form.querySelector('[name*="dealCustomFields"]'); 17 } 18 19 // ------------------------------------------------------------ 20 // 2. ÐонÑигÑÑаÑии полей, коÑоÑÑе нÑжно ÑоздаÑÑ 21 // ------------------------------------------------------------ 22 23 // ÐÐ¾Ð»Ñ Ð¿Ð¾Ð»ÑзоваÑÐµÐ»Ñ (добавлÑÑÑÑÑ Ð²Ð¾ вÑе ÑоÑмÑ) 24 const userFields = [ 25 { id: 'field-input-739996', name: 'formParams[userCustomFields][739996]', type: 'hidden' }, 26 { id: 'field-input-739997', name: 'formParams[userCustomFields][739997]', type: 'hidden' }, 27 { id: 'field-input-739998', name: 'formParams[userCustomFields][739998]', type: 'hidden' }, 28 { id: 'field-input-740000', name: 'formParams[userCustomFields][740000]', type: 'hidden' }, 29 { id: 'field-input-739999', name: 'formParams[userCustomFields][739999]', type: 'hidden' }, 30 { id: 'field-input-744280', name: 'formParams[userCustomFields][744280]', type: 'hidden' }, 31 { id: 'field-input-1321986', name: 'formParams[userCustomFields][1321986]', type: 'hidden' }, 32 { id: 'field-input-10931535', name: 'formParams[userCustomFields][10931535]', type: 'hidden' }, 33 { id: 'field-input-10956429', name: 'formParams[userCustomFields][10956429]', type: 'hidden' }, 34 { id: 'field-input-10969184', name: 'formParams[userCustomFields][10969184]', type: 'textarea', className: 'form-control hidden', rows: '5' } 35 ]; 36 37 // ÐÐ¾Ð»Ñ Ð·Ð°ÐºÐ°Ð·Ð° (добавлÑÑÑÑÑ ÑолÑко в ÑоÑмÑ, ÑодеÑжаÑие dealCustomFields) 38 const dealFields = [ 39 { id: 'field-input-476955', name: 'formParams[dealCustomFields][476955]', type: 'hidden' }, 40 { id: 'field-input-476956', name: 'formParams[dealCustomFields][476956]', type: 'hidden' }, 41 { id: 'field-input-476957', name: 'formParams[dealCustomFields][476957]', type: 'hidden' }, 42 { id: 'field-input-476981', name: 'formParams[dealCustomFields][476981]', type: 'hidden' }, 43 { id: 'field-input-476982', name: 'formParams[dealCustomFields][476982]', type: 'hidden' }, 44 { id: 'field-input-476983', name: 'formParams[dealCustomFields][476983]', type: 'hidden' }, 45 { id: 'field-input-1321983', name: 'formParams[dealCustomFields][1321983]', type: 'hidden' }, 46 { id: 'field-input-1427984', name: 'formParams[dealCustomFields][1427984]', type: 'hidden' }, 47 { id: 'field-input-1464880', name: 'formParams[dealCustomFields][1464880]', type: 'hidden' }, 48 { id: 'field-input-1464881', name: 'formParams[dealCustomFields][1464881]', type: 'hidden' }, 49 { id: 'field-input-10931534', name: 'formParams[dealCustomFields][10931534]', type: 'hidden' }, 50 { id: 'field-input-10956442', name: 'formParams[dealCustomFields][10956442]', type: 'hidden' }, 51 { id: 'field-input-11960537', name: 'formParams[dealCustomFields][11960537]', type: 'hidden' }, 52 { id: 'field-input-12511430', name: 'formParams[dealCustomFields][12511430]', type: 'textarea', className: 'form-control hidden', rows: '3' }, 53 { id: 'field-input-11493624', name: 'formParams[dealCustomFields][11493624]', type: 'hidden' } 54 ]; 55 56 // ------------------------------------------------------------ 57 // 3. ФÑнкÑÐ¸Ñ Ð´Ð»Ñ ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ Ð¾Ð´Ð½Ð¾Ð³Ð¾ Ð¿Ð¾Ð»Ñ 58 // ------------------------------------------------------------ 59 function createField(cfg) { 60 let el = cfg.type === 'textarea' ? document.createElement('textarea') : document.createElement('input'); 61 if (cfg.type !== 'textarea') el.type = cfg.type; 62 el.id = cfg.id; 63 el.name = cfg.name; 64 el.value = ''; 65 if (cfg.className) el.className = cfg.className; 66 if (cfg.rows) el.rows = cfg.rows; 67 return el; 68 } 69 70 function fieldExists(form, id, name) { 71 return form.querySelector(`#${id}, [name="${name}"]`); 72 } 73 74 // ------------------------------------------------------------ 75 // 4. ÐобавлÑем Ð¿Ð¾Ð»Ñ Ð²Ð¾ вÑе ÑоÑÐ¼Ñ Ð½Ð° ÑÑÑаниÑе 76 // ------------------------------------------------------------ 77 document.querySelectorAll('form').forEach(form => { 78 userFields.forEach(cfg => { 79 if (!fieldExists(form, cfg.id, cfg.name)) { 80 form.appendChild(createField(cfg)); 81 } 82 }); 83 if (isOrderForm(form)) { 84 dealFields.forEach(cfg => { 85 if (!fieldExists(form, cfg.id, cfg.name)) { 86 form.appendChild(createField(cfg)); 87 } 88 }); 89 } 90 });
91 92 // ------------------------------------------------------------ 93 // 5. Ðаполнение полей знаÑениÑми (UTM, URL, YID) 94 // ------------------------------------------------------------ 95 96 // 5.1. СпиÑок UTM-паÑамеÑÑов Ñ ÑелекÑоÑами полей 97 const UTMS = [ 98 ['utm_source', '#field-input-739996'], 99 ['utm_medium', '#field-input-739997'], 100 ['utm_campaign', '#field-input-739998'], 101 ['utm_content', '#field-input-740000'], 102 ['utm_term', '#field-input-739999'], 103 ['mailid', '#field-input-744280'], 104 ['cl_uid', '#field-input-1321983'], 105 ['utm_source', '#field-input-476955'], 106 ['utm_medium', '#field-input-476956'], 107 ['utm_campaign', '#field-input-476957'], 108 ['utm_content', '#field-input-476981'], 109 ['utm_term', '#field-input-476982'], 110 ['mailid', '#field-input-476983'], 111 ['cl_uid', '#field-input-1321986'], 112 ['publ_uid', '#field-input-1427984'], 113 ['cl_uid1', '#field-input-1464880'], 114 ['sub8', '#field-input-1464881'], 115 ['admitad_uid', '#field-input-10931535'], 116 ['admitad_uid', '#field-input-10931534'], 117 ['refLinkId', '#field-input-11935368'], 118 ['URL', '#field-input-11960537'] 119 ]; 120 121 function getUTM(name, selector) { 122 const inputs = document.querySelectorAll(selector); 123 if (inputs.length === 0) return; 124 const match = decodeURIComponent(window.location.search).match(new RegExp(name + '=([^&=]+)')); 125 if (match) { 126 inputs.forEach(input => input.value = decodeURI(match[1])); 127 } 128 } 129 130 function setDomainWithPath(selector) { 131 const inputs = document.querySelectorAll(selector); 132 if (inputs.length === 0) return; 133 const value = window.location.hostname + window.location.pathname; 134 inputs.forEach(input => { 135 input.value = value; 136 ['input', 'change', 'keyup', 'blur'].forEach(eventType => { 137 input.dispatchEvent(new Event(eventType, { bubbles: true })); 138 }); 139 }); 140 } 141 142 // 5.2. ÐолÑÑение Yandex UID из кÑк 143 function getYandexUid() { 144 try { 145 const cookies = document.cookie.split(';'); 146 for (let i = 0; i < cookies.length; i++) { 147 const cookie = cookies[i].trim(); 148 if (cookie.indexOf('_ym_uid=') === 0) { 149 return cookie.substring('_ym_uid='.length); 150 } 151 } 152 return null; 153 } catch(e) { 154 return null; 155 } 156 } 157 158 // 5.3. Ðаполнение Ð¿Ð¾Ð»Ñ yid 159 function setYandexUidField(value) { 160 const fields = document.querySelectorAll('#field-input-11493624'); 161 if (fields.length === 0) return false; 162 let anyFilled = false; 163 fields.forEach(field => { 164 if (field && value && (!field.value || field.value.trim() === '')) { 165 field.value = value; 166 ['input', 'change', 'keyup', 'blur'].forEach(eventType => { 167 field.dispatchEvent(new Event(eventType, { bubbles: true })); 168 }); 169 anyFilled = true; 170 } 171 }); 172 return anyFilled; 173 } 174 175 // 5.4. ÐÑновное заполнение (пеÑиодиÑеÑкое) 176 setInterval(() => { 177 // ÐаполнÑем UTM и URL 178 UTMS.forEach(([name, selector]) => { 179 if (name === 'URL') { 180 setDomainWithPath(selector); 181 } else { 182 getUTM(name, selector); 183 } 184 }); 185 186 // ÐаполнÑем YID, еÑли поле еÑÑ Ð¿ÑÑÑое 187 const yandexUid = getYandexUid(); 188 if (yandexUid) { 189 setYandexUidField(yandexUid); 190 } 191 }, 500); 192});
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.