Skip to content

Commit

Permalink
Remove dbg from polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
raducristianpopa committed Feb 28, 2024
1 parent 4146781 commit c0907a1
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions src/content/static/polyfill.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// language=JavaScript
export const wm2Polyfill = `
const dbg = () => {
}
dbg('setonmonetization property start')
const handlers = new WeakMap()
var attributes = {
enumerable: true,
Expand All @@ -11,15 +8,13 @@ export const wm2Polyfill = `
return handlers.get(this) || null
},
set(val) {
dbg('set onmonetization called, with', val)
const listener = handlers.get(this)
if (listener && listener === val) {
// nothing to do here ?
return
}
const removeAnyExisting = () => {
if (listener) {
dbg('removing existing listener')
this.removeEventListener('monetization', listener)
}
}
Expand Down Expand Up @@ -59,8 +54,6 @@ export const wm2Polyfill = `
Object.defineProperty(HTMLElement.prototype, 'onmonetization', attributes)
Object.defineProperty(Window.prototype, 'onmonetization', attributes)
Object.defineProperty(Document.prototype, 'onmonetization', attributes)
dbg('setonmonetization property end')
dbg('add coil-onmonetization-v2-attr-changed handler start')
//
class MonetizationEvent extends Event {
Expand All @@ -77,16 +70,12 @@ export const wm2Polyfill = `
window.MonetizationEvent = MonetizationEvent
window.addEventListener('monetization-v2', (event) => {
dbg(
'monetization-v2 event'
)
const monetizationTag = document.querySelector('link[rel="monetization"]');
const monetizationEvent = new MonetizationEvent('monetization', event.detail)
monetizationTag.dispatchEvent(monetizationEvent)
}, { capture: true, bubble: true })
window.addEventListener('onmonetization-attr-changed', (event) => {
dbg('onmonetization-attr-changed', event.detail.attribute)
const { attribute } = event.detail
if (attribute) {
// TODO:WM2 what are the CSP issues here?
Expand All @@ -97,5 +86,4 @@ export const wm2Polyfill = `
event.target.onmonetization = null
}
}, { capture: true })
dbg('add coil-onmonetization-v2-attr-changed handler end')
`

0 comments on commit c0907a1

Please sign in to comment.