编辑网页元素

可视化选中网页元素,并根据需求编辑

< Feedback on 编辑网页元素

Review: Good - script works

§
Posted: 2023-12-20

function savePosition() {
GM_setValue('selectDomPosition', JSON.stringify({
x: seledom.offsetLeft,
y: seledom.offsetTop
}));
}

function restorePosition() {
const position = GM_getValue('selectDomPosition');
if (position) {
const { x, y } = JSON.parse(position);
seledom.style.left = `${x}px`;
seledom.style.top = `${y}px`;
}
}
// 在 pobut 的 mousedown 事件中调用 savePosition
pobut.addEventListener('mousedown', () => {
savePosition();
});

// 调用 restorePosition
restorePosition();

Post reply

Sign in to post a reply.