Allows editing text on any webpage by clicking a button with improved styling
ของเมื่อวันที่
// ==UserScript==
// @name Page Text Editor
// @namespace http://tampermonkey.net/
// @version 1.8
// @description Allows editing text on any webpage by clicking a button with improved styling
// @author Rylogix
// @match https://*/*
// @match http://*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function enableEditMode() {
document.querySelectorAll('*').forEach(function(node) {
node.setAttribute('contenteditable', 'true');
});
}
function disableEditMode() {
document.querySelectorAll('*').forEach(function(node) {
node.removeAttribute('contenteditable');
});
}
var editButton = document.createElement('button');
editButton.innerHTML = 'Edit Text';
editButton.style.position = 'fixed';
editButton.style.top = '10px';
editButton.style.right = '10px';
editButton.style.padding = '8px 12px';
editButton.style.border = 'none';
editButton.style.borderRadius = '5px';
editButton.style.background = '#3498db';
editButton.style.color = '#fff';
editButton.style.fontFamily = 'Arial, sans-serif';
editButton.style.fontSize = '14px';
editButton.style.cursor = 'pointer';
editButton.style.userSelect = 'none'; // Prevent text selection
editButton.onclick = function() {
if (editButton.innerHTML === 'Edit Text') {
enableEditMode();
editButton.innerHTML = 'Stop Editing';
} else {
disableEditMode();
editButton.innerHTML = 'Edit Text';
}
};
document.body.appendChild(editButton);
})();