Guest User

Untitled

a guest
Jan 24th, 2026
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. /***** manifest.json *****/
  2.  
  3. {
  4. "manifest_version": 3,
  5. "name": "Clipboard Alert",
  6. "version": "1.0",
  7. "description": "Shows the current clipboard contents in an alert.",
  8. "permissions": [
  9. "activeTab",
  10. "scripting",
  11. "clipboardRead"
  12. ],
  13. "background": {
  14. "scripts": [
  15. "background.js"
  16. ]
  17. },
  18. "action": {
  19. "default_title": "Show Clipboard"
  20. }
  21. }
  22.  
  23. /***** background.js *****/
  24.  
  25. browser.action.onClicked.addListener(async (tab) => {
  26. if (!tab.id) return;
  27.  
  28. try {
  29. await browser.scripting.executeScript({
  30. target: { tabId: tab.id },
  31. func: async () => {
  32. try {
  33. const text = await navigator.clipboard.readText();
  34. alert("Clipboard contents:\n\n" + text);
  35. } catch (err) {
  36. alert("Failed to read clipboard:\n" + err);
  37. }
  38. }
  39. });
  40. } catch (e) {
  41. console.error("Script injection failed:", e);
  42. }
  43. });
  44.  
  45.  
Advertisement
Add Comment
Please, Sign In to add comment