Remove capture attribute + Notification

Removes the 'capture' attribute from <input> elements and shows a toast-style notification when it's done.

ของเมื่อวันที่ 25-04-2025 ดู เวอร์ชันล่าสุด

// ==UserScript==
// @name         Remove capture attribute + Notification
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Removes the 'capture' attribute from <input> elements and shows a toast-style notification when it's done.
// @author       You
// @match        *://*.jzetech.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
  'use strict';

  /**
   * Creates and shows a floating notification on the page.
   * @param {string} message - The message to display.
   */
  function showNotification(message) {
    const toast = document.createElement('div');
    toast.textContent = message;
    Object.assign(toast.style, {
      position: 'fixed',
      top: '20px',
      right: '20px',
      backgroundColor: '#4CAF50',
      color: '#fff',
      padding: '10px 16px',
      borderRadius: '8px',
      fontSize: '14px',
      boxShadow: '0 2px 8px rgba(0,0,0,0.2)',
      zIndex: 9999,
      opacity: 0,
      transition: 'opacity 0.5s',
    });

    document.body.appendChild(toast);
    requestAnimationFrame(() => {
      toast.style.opacity = 1;
    });

    setTimeout(() => {
      toast.style.opacity = 0;
      setTimeout(() => toast.remove(), 500);
    }, 3000);
  }

  /**
   * Removes the 'capture' attribute from all input elements on the page.
   * Also displays a toast message if any changes are made.
   */
  function removeCaptureAttribute() {
    const inputsWithCapture = document.querySelectorAll('input[capture]');
    if (inputsWithCapture.length > 0) {
      inputsWithCapture.forEach(input => {
        console.log('Removed capture attribute from:', input);
        input.removeAttribute('capture');
      });
      showNotification(`🎉 Removed 'capture' from ${inputsWithCapture.length} input(s)`);
    }
  }

  // Run immediately on page load
  removeCaptureAttribute();

  // Observe DOM changes for dynamically added elements
  const observer = new MutationObserver(removeCaptureAttribute);
  observer.observe(document.body, { childList: true, subtree: true });
})();