react-scan icon indicating copy to clipboard operation
react-scan copied to clipboard

Browser Bookmark

Open SukkaW opened this issue 1 year ago β€’ 5 comments

Just add a bookmark with the following URL:

javascript:void((() => { const s = document.head.appendChild(document.createElement('script'));s.src = 'https://unpkg.com/react-scan/dist/auto.global.js';s.onerror = () => alert('Failed to load react-scan!')})())

And now one-click enable React Scan for any websites~

SukkaW avatar Nov 23 '24 09:11 SukkaW

https://mourner.github.io/bullshit.js/ is an example of a bookmarklet help page you can look at

alirobe avatar Nov 26 '24 12:11 alirobe

@SukkaW This is brilliant, thank you so much! Should be in official docs

adnan-smlatic avatar Nov 29 '24 12:11 adnan-smlatic

The only issue with this is CSP... but otherwise, it’s a fantastic approach! I also use bookmarks for small and super useful things πŸ˜‰.

edit:

Something like this can be added to the site ;)

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>React-Scan Bookmarklet Installer</title>
</head>
<body>
  <h1>Add the React-Scan Bookmarklet</h1>
  <p>Drag the button below to your bookmarks bar to install the bookmarklet:</p>

  <a
    href="javascript:void((() => { const s = document.head.appendChild(document.createElement('script'));s.src = 'https://unpkg.com/react-scan/dist/auto.global.js';s.onerror = () => alert('Failed to load react-scan!')})())"
    style="padding: 10px; background-color: purple; color: white; text-decoration: none; border-radius: 5px;"
  >
    React-Scan
  </a>

  <p>If you can't see your bookmarks bar, press <strong>Ctrl+Shift+B</strong> (Windows) or <strong>Cmd+Shift+B</strong> (Mac) to enable it.</p>
</body>
</html>

pivanov avatar Dec 02 '24 20:12 pivanov

The only issue with this is CORS

I don't get it, the script tag should not cause any CORS issues. The CSP would be the only issue.

SukkaW avatar Dec 03 '24 01:12 SukkaW

The only issue with this is CORS

I don't get it, the script tag should not cause any CORS issues. The CSP would be the only issue.

Oh, my bad! πŸ™ˆ I've been working on some CORS issues in another project, and the word just stuck in my head.

pivanov avatar Dec 03 '24 02:12 pivanov