|
| 1 | +import {validateData, writeScript} from '#3p/3p'; |
| 2 | + |
| 3 | +/** |
| 4 | + * @param {!Window} global |
| 5 | + * @param {!Object} data |
| 6 | + */ |
| 7 | +export function yobee(global, data) { |
| 8 | + validateData(data, ['adNetwork', 'adPublisher', 'adTypeId']); |
| 9 | + global._yobee = global._yobee || { |
| 10 | + adNetwork: data['adPublisher'], |
| 11 | + publisher: data['adNetwork'], |
| 12 | + adTypeId: data['adTypeId'], |
| 13 | + host: `static.cdn.yobee.it`, |
| 14 | + prefix: `ybe`, |
| 15 | + }; |
| 16 | + |
| 17 | + const ins = global.document.createElement('ins'); |
| 18 | + ins.setAttribute('data-publisher', global._yobee.publisher); |
| 19 | + if (global._yobee.adTypeId == 'standard') { |
| 20 | + ins.setAttribute('data-ad-size', `[[${data.width},${data.height}]]`); |
| 21 | + } |
| 22 | + ins.setAttribute('data-ad-network', global._yobee.adNetwork); |
| 23 | + ins.setAttribute('data-ad-type-id', global._yobee.adTypeId); |
| 24 | + ins.setAttribute('class', `${global._yobee.prefix}-ads-area`); |
| 25 | + global.document.getElementById('c').appendChild(ins); |
| 26 | + ins.parentNode.addEventListener('eventAdbladeRenderStart', () => |
| 27 | + global.context.renderStart() |
| 28 | + ); |
| 29 | + writeScript(global, `https://${global._yobee.host}/showad/showad.min.js`); |
| 30 | +} |
0 commit comments