# Warp any DOM element with this bookmarklet

DevFeed: [Warp any DOM element with this bookmarklet](<https://devfeed.tech/articles/warp-any-dom-element-with-this-bookmarklet-28096.md>)

Original publisher: [Read original article](<https://jlongster.com/warp-any-dom-element-with-this-bookmarklet>)

Author: James Long

Published: 2025-11-19T12:00:00Z

Content type: tutorial

Language: en

Sources: [James Long](<https://devfeed.tech/sources/james-long.md>)

Topics: [Warp](<https://devfeed.tech/topics/warp.md>), [Document Object Model (DOM)](<https://devfeed.tech/topics/dom.md>), [Snippet](<https://devfeed.tech/topics/snippet.md>)

Tags: [js](<https://devfeed.tech/tags/js.md>), [snippet](<https://devfeed.tech/tags/snippet.md>), [warp](<https://devfeed.tech/tags/warp.md>)

## AI overview

This article presents a JavaScript bookmarklet for interactively selecting a DOM element and applying a visual warp effect to it. The code includes element highlighting, selection, draggable control points, and cleanup behavior.

## Source excerpt

I've been working on a design and found a cool effect that would make a great bookmarklet. A bookmarklet is a JS snippet that you can drag to your bookmarks bar and run on any page. Press ESC to cancel`;const closeBtn=document.createElement('button');closeBtn.textContent='✕ Close';closeBtn.style.cssText=`padding: 6px 12px;background: #ef4444;color: white;border: none;border-radius: 4px;cursor: pointer;font-weight: 500;font-size: 12px;margin-left: auto;`;closeBtn.onclick=cleanup;instructions.appendChild(instructionText);instructions.appendChild(closeBtn);document.body.appendChild(instructions);document.addEventListener('mousemove',onSelectorMove);document.addEventListener('click',onSelectorClick);document.addEventListener('keydown',(e)=>{if(e.key==='Escape')cleanup();});window.__bezierCleanup=()=>{instructions.remove();cleanup();};}function onSelectorMove(e){if(!selectorActive)return;const target=document.elementFromPoint(e.clientX,e.clientY);if(!target||target===highlightBox)return;const rect=target.getBoundingClientRect();highlightBox.style.display='block';highlightBox.style.left=rect.left+'px';highlightBox.style.top=rect.top+'px';highlightBox.style.width=rect.width+'px';highlightBox.style.height=rect.height+'px';}function onSelectorClick(e){if(!selectorActive)return;e.preventDefault();e.stopPropagation();const target=document.elementFromPoint(e.clientX,e.clientY);if(!target)return;selectorActive=false;highlightBox.style.display='none';document.removeEventListener('mousemove',onSelectorMove);document.removeEventListener('click',onSelectorClick);selectElement(target);}function selectElement(element){selectedElement=element;const rect=element.getBoundingClientRect();const scrollX=window.pageXOffset||document.documentElement.scrollLeft;const scrollY=window.pageYOffset||document.documentElement.scrollTop;transformedContainer=document.createElement('div');transformedContainer.style.cssText=`position: absolute;left: ${rect.left+scrollX}px;top: ${rect.top+scrollY}px;width