Created
November 19, 2023 12:16
-
-
Save TheLustriVA/28abbd00de13d94b34b00f23c3d0b32c to your computer and use it in GitHub Desktop.
Limerick linter - JS Bookmarklet - Draft - GPT4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Creating a JavaScript bookmarklet as you described involves a few steps. First, you need the code for the bookmarklet itself, and then you'll need to add it to your browser as a bookmark. Here's a step-by-step guide: | |
### Step 1: JavaScript Bookmarklet Code | |
The JavaScript code will create a small application on any webpage you visit. It will display a 5-line text input for the limerick, the rhyming scheme, and the meter representation. As you type each line of the limerick, it will check if the line conforms to the rhyming scheme and meter, showing a tick or cross accordingly. | |
Here's the JavaScript code: | |
```javascript | |
javascript: (function() { | |
var script = document.createElement('script'); | |
script.onload = function() { | |
var div = document.createElement('div'); | |
div.style.position = 'fixed'; | |
div.style.top = '10px'; | |
div.style.left = '10px'; | |
div.style.backgroundColor = 'white'; | |
div.style.border = '1px solid black'; | |
div.style.padding = '10px'; | |
div.innerHTML = `<h3>Limerick Checker</h3> | |
<textarea id="limerickInput" rows="5" cols="40" placeholder="Type your limerick here..."></textarea> | |
<p>Rhyme Scheme: aaA aaA bbB bbB aaA</p> | |
<p>Meter: - - / - - / - - / (8-9 syllables)</p> | |
<p>Meter: - - / - - / (5-6 syllables)</p> | |
<div id="feedback"></div>`; | |
document.body.appendChild(div); | |
var input = document.getElementById('limerickInput'); | |
input.onkeyup = function() { | |
var text = input.value.split('\\n'); | |
var feedback = ''; | |
// Check each line for rhyme and meter | |
// Add your logic here to check each line | |
// Update feedback with ticks or crosses | |
document.getElementById('feedback').innerHTML = feedback; | |
}; | |
}; | |
script.src = 'https://code.jquery.com/jquery-3.5.1.min.js'; | |
document.head.appendChild(script); | |
})(); | |
``` | |
### Step 2: Adding the Bookmarklet to Your Browser | |
1. **Create a New Bookmark**: Right-click on your bookmarks bar in your browser and choose 'Add Page' or 'Add Bookmark' (the exact option depends on your browser). | |
2. **Set the Name**: Give your bookmark a name like "Limerick Checker". | |
3. **Add the Code**: In the URL or Location field of the bookmark, copy and paste the entire JavaScript code provided above. | |
4. **Save the Bookmark**: Save the bookmark. | |
### Using the Bookmarklet | |
1. **Open a Web Page**: Go to any web page where you want to use the tool. | |
2. **Click the Bookmark**: Click on the "Limerick Checker" bookmark in your bookmarks bar. This will open the limerick checker on the current page. | |
3. **Use the Tool**: Start typing your limerick in the text box. The tool will provide feedback as you type. | |
### Note: | |
- The bookmarklet code provided is a basic template. You will need to add the specific logic to check the rhyme scheme and meter for each line, which can be complex due to the intricacies of natural language processing. | |
- This bookmarklet depends on jQuery, which is loaded from a CDN. Ensure you're using it on pages where external scripts can be loaded. | |
- Since you use, this should work well in browsers like Firefox or Chrome. | |
Let me know if you need further assistance with this! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment