const logCount = 0 const defaultLog = console.log console.log = (...args) => { if(matchMedia('only screen and (max-width: 760px)').matches){ if(!window.mobileConsoleDiv){ const d = document.createElement('div') d.style = 'position:absolute;top:0px;' d.id = 'mobileConsoleDiv' document.body.appendChild(d) } const d = document.createElement('div') d.innerText = args.join(' ') d.style = `background-color: white;padding:3px;border:1px solid grey` mobileConsoleDiv.appendChild(d) setTimeout(_=>{ d.remove() if(!logCount){ window.mobileConsoleDiv.remove() } }, 3000) }else{ defaultLog(...args) } }