please create a bookmrklet that counts the words of selected text and show them in a…
- User
please create a bookmrklet that counts the words of selected text and show them in a message
- Assistant
To create a bookmarklet that counts the words of selected text and shows them in a message, follow these steps:
-
Create a new bookmark in your browser. You can do this by right-clicking on the bookmarks toolbar and selecting "Add Page" or "Add Bookmark" (the wording might be different depending on your browser).
-
Name the bookmark "Word Counter" or any other name you prefer.
-
In the URL or Location field, paste the following JavaScript code:
javascript:(function(){var t=window.getSelection().toString().trim().replace(/(\r\n|\n|\r)/gm,' ').split(/\s+/).length;alert('Word count: '+t);})();- Save the bookmark.
Now, whenever you want to count the words of selected text, simply select the text and click the "Word Counter" bookmarklet. A message will appear with the word count.
Please note that this bookmarklet may not work on certain websites due to security restrictions.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.