JavaScript Code Snippets

Add watermark

document.getElementsByTagName('body')[0].style.backgroundImage = 'url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' version=\'1.1\' height=\'100px\' width=\'100px\'><text transform=\'translate(20, 100) rotate(-30)\' fill=\'rgba(128,128,128, 0.3)\' font-size=\'20\' >watermark</text></svg>")';
const div = document.createElement("div");
div.innerHTML = `<div id="watermark" style="position: fixed; top: 0px; left: 0px; width: 100%; height: 100%; background-image: url(&quot;data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' width='440px' height='293.3333333333333px'><text transform='translate(5, 100) rotate(-20)' fill='rgba(128,128,128, 0.3)' font-size='20' >watermark</text></svg>&quot;); background-repeat: repeat; background-size: 300px 200px; pointer-events: none; z-index: 9999; opacity: 0.5;"></div>`;
document.body.appendChild(div);