Here's a "fix" for underlining hyperlinks in your posts.

bnew

Veteran
Joined
Nov 1, 2015
Messages
54,839
Reputation
8,165
Daps
155,131
ever since thecoli upgraded, hyperlinks are no longer underlined, even in old threads. I used ChatGPT to create a bookmarklet to underline hyperlinks in posts in edit mode. for it to work the bbcode editor must be enabled instead of the default html editor.

this is the bookmarklet code.
Code:
javascript:(function() {  var textarea = document.querySelector('textarea.input[name="message"]');  var text = textarea.value;  var pattern = /\[URL=(.*?)\[\/URL\]/g;  var replacedText = text.replace(pattern, %27[U][URL=$1[/URL][/U]%27);  textarea.value = replacedText;})();

** you can follow the instructions below or just highlight the code(doubleclick) and drag and drop it to the bookmark bar, then right-click edit it.

To use this bookmarklet:

  1. Create a new bookmark in your Chromium browser.
  2. Right-click on the bookmarks bar and choose "Add Page" or "Add Bookmark" (the option may vary depending on your browser version).
  3. Enter a name for the bookmarklet (e.g., "Format Text").
  4. In the "URL" or "Address" field, paste the above JavaScript code.
  5. Save the bookmark.
  6. Navigate to the page with the <textarea> element you want to edit.
  7. Click on the bookmarklet you created.
  8. The desired find and replace action will be applied to the content of the specified <textarea> element.

copy paste the text into the "html editor" , switch to "bb code", click bookmarklet and switch back to the html editor.


Toggle the "BB code" button and then the buttons to the left should turn grey.
1gNRnIE.png


click the newly created bb code underline bookmarklet, I named mines "bb_" but you can name it anyway you want.
emegGtt.png


example:
Xz639g3.png
 
Last edited:

bnew

Veteran
Joined
Nov 1, 2015
Messages
54,839
Reputation
8,165
Daps
155,131
for some reason pasting text from sites will results in no empty lines between paragraphs like the text in the screenshot above shows. I made chatgpt create a bookmarklet to separate paragraph's of a post with one-click.

javascript:(function() { var textareas = document.querySelectorAll('textarea.input'); textareas.forEach(function(textarea) { var text = textarea.value; var pattern = /(\n)([A-Z"])/g; var replacedText = text.replace(pattern, '$1\n$2'); textarea.value = replacedText; });})();
 
Last edited:

bnew

Veteran
Joined
Nov 1, 2015
Messages
54,839
Reputation
8,165
Daps
155,131
YOU CAN JUST UNDERLINE MANUALLY LIKE THIS


when theres a whole bunch of links in an article, it then becomes tedious to carefully highlight one or more words to you can then underline them, the bookmarklet is a one click solution whether you're dealing with one link or a hundred.
 

Sccit

LA'S MOST BLUNTED
Bushed
WOAT
Supporter
Joined
Jun 22, 2013
Messages
56,135
Reputation
-19,866
Daps
75,063
Reppin
LOS818ANGELES
when theres a whole bunch of links in an article, it then becomes tedious to carefully highlight one or more words to you can then underline them, the bookmarklet is a one click solution whether you're dealing with one link or a hundred.


THIS FORUM NEEDS ANOTHER ADMIN
 

bnew

Veteran
Joined
Nov 1, 2015
Messages
54,839
Reputation
8,165
Daps
155,131
I updated the bookmarklet to fix some formatting issues.

```
Code:
javascript:(function() {
 var textareas = document.querySelectorAll('textarea.input');
 textareas.forEach(function(textarea) {
     var text = textarea.value;
     var pattern1 = /\[URL=(.*?)\[\/URL\]/g;
     var pattern2 = /(\n)([A-Z"]|\d|\[B\]|\[I\]|\[IMG\])/g;
     var pattern3 = /\[IMG alt="([^"]*)"/g;
     var pattern4 = /\n/g;
     var pattern5 = /(\[HEADING=2\]|\[LIST\]|\[\*\)|\[\/LIST\]|\[IMG\])/g;
     var replacedText = text.replace(pattern1, '[U][URL=\$1[/URL][/U]');
     replacedText = replacedText.replace(pattern2, '\$1\n\$2');
     replacedText = replacedText.replace(pattern3, '\n[IMG alt="$1"');
     replacedText = replacedText.replace(pattern4, '\n\n');
     replacedText = replacedText.replace(pattern5, '\n\$1');
     replacedText = replacedText.replace(/\n{4,}/g, '\n\n');
     replacedText = replacedText.replace(/\[U\]\[U\]\[URL=(.*?)\[\/URL\]\[\/U\]\[\/U\]/g, '[U][URL=\$1[/URL][/U]');
     replacedText = replacedText.replace(/\[\/HEADING\]\n/g, '[/HEADING]');
     replacedText = replacedText.replace(/\[\/IMG\]\n/g, '[/IMG]');
     textarea.value = replacedText;
 });
})();
```

The modified bookmarklet you provided is a JavaScript code that manipulates the text content of all textarea elements with the class "input". It applies several changes to the text content of these textareas, which is stored in thetextarea.valuevariable.

Here's a breakdown of the changes you made:

1. **Pattern 3**: You've changed the pattern from/\*)"/g to/\[IMG alt="([^"]*)"/g. This pattern matches any text that starts with[IMG alt=" and ends with"]. The([^"]*) part is a capturing group that matches any character except a double quote (`"`), repeated any number of times. Theg at the end of the pattern indicates that this pattern should be applied globally, i.e., it should match all occurrences in the string, not just the first one.

2. **Replacement for Pattern 3**: You've changed the replacement string from'\n[IMG alt="$1"' to'\n[IMG alt="$1"'. This means that for each match of the pattern in the text, it will be replaced with a newline character followed by[IMG alt=", followed by the captured group (represented by$1), and ending with"].

Now, let's discuss what the bookmarklet does:

1. **Pattern 1**: This pattern matches any text that starts with[URL= and ends with[/URL]. The([^"]*) part is a capturing group that matches any character except a double quote (`"`), repeated any number of times. Theg at the end of the pattern indicates that this pattern should be applied globally.

2. **Replacement for Pattern 1**: For each match of the pattern in the text, it is replaced with[U][URL=$1[/URL][/U]. Here, $1 represents the captured group in the pattern, which is the URL inside the[URL= and[/URL] tags.

3. **Pattern 2**: This pattern matches any newline character followed by a space, a capital letter, a double quote, or a digit, or any of the specified special tags.

4. **Replacement for Pattern 2**: For each match of the pattern in the text, it is replaced with a newline character followed by the captured group (represented by$1), followed by another newline character.

5. **Pattern 4**: This pattern matches any newline character.

6. **Replacement for Pattern 4**: For each match of the pattern in the text, it is replaced with two newline characters.

7. **Pattern 5**: This pattern matches any of the specified special tags.

8. **Replacement for Pattern 5**: For each match of the pattern in the text, it is replaced with a newline character followed by the captured group (represented by$1).

9. **Final Replacement**: The text is then further processed to remove any occurrence of four or more consecutive newline characters, and to remove any occurrence of[U][U][URL= and[/URL][/U][/U] tags.

Finally, the modified text is set as the value of the textarea. This means that the changes will be reflected in the textarea when you run the bookmarklet.

this is what it does with bbcode enabled

uisEYwe.gif



edit:

updated it again to fix posts with poor html formatting

This modified bookmarklet will now remove any matches for the FONT and COLOR tags in addition to the existing operations. The g flag at the end of each regular expression ensures that the replace operation is performed globally, i.e., all occurrences of the pattern in the string are replaced, not just the first one

Code:
javascript:(function() {
 var textareas = document.querySelectorAll('textarea.input');
 textareas.forEach(function(textarea) {
     var text = textarea.value;
     var pattern1 = /\[URL=(.*?)\[\/URL\]/g;
     var pattern2 = /(\n)([A-Z"]|\d|\[B\]|\[I\]|\[IMG\])/g;
     var pattern3 = /\[IMG alt="([^"]*)"/g;
     var pattern4 = /\n/g;
     var pattern5 = /(\[HEADING=2\]|\[LIST\]|\[\*\)|\[\/LIST\]|\[IMG\])/g;
     var pattern6 = /\[\/?FONT(=.*?)?\]/g;
     var pattern7 = /\[\/?COLOR(=.*?)?\]/g;
     var replacedText = text.replace(pattern1, '[U][URL=\$1[/URL][/U]');
     replacedText = replacedText.replace(pattern2, '\$1\n\$2');
     replacedText = replacedText.replace(pattern3, '\n[IMG alt="$1"');
     replacedText = replacedText.replace(pattern4, '\n\n');
     replacedText = replacedText.replace(pattern5, '\n\$1');
     replacedText = replacedText.replace(pattern6, '');
     replacedText = replacedText.replace(pattern7, '');
     replacedText = replacedText.replace(/\n{4,}/g, '\n\n');
     replacedText = replacedText.replace(/\[U\]\[U\]\[URL=(.*?)\[\/URL\]\[\/U\]\[\/U\]/g, '[U][URL=\$1[/URL][/U]');
     replacedText = replacedText.replace(/\[\/HEADING\]\n/g, '[/HEADING]');
     replacedText = replacedText.replace(/\[\/IMG\]\n/g, '[/IMG]');
     textarea.value = replacedText;
 });
})();
 
Last edited:

bnew

Veteran
Joined
Nov 1, 2015
Messages
54,839
Reputation
8,165
Daps
155,131
I updated the bookmarklet to match the pattern [/?INDENT(?:=\d\d?)?] and replace it with an empty string.

I was seeing BBCODE like the one below after I copied some HTML to post and it messed up the formatting so i had to update the bookmarklet.

[CODE][INDENT=10][SIZE=0px][IMG width="960px" alt="Photo Illustration: The Chinese flag and a crowd of people"]https://media-cldnry.s-nbcnews.com/image/upload/t_fit-760w,f_auto,q_auto:best/rockcms/2023-11/231129-china-media-manipulation-jg-a98a2c.jpg[/IMG][/SIZE][/INDENT]

[COLOR=var(--caption--color)][INDENT=10][COLOR=var(--caption--source--color)]Justine Goode / NBC News; Getty Images[/COLOR][/INDENT][/COLOR][/COLOR][/FONT][/SIZE][/CODE]



Code:
javascript:(function() {
   var textareas = document.querySelectorAll('textarea.input');
   textareas.forEach(function(textarea) { 
       var text = textarea.value; 
       var pattern1 = /\[URL=(.*?)\[\/URL\]/g; 
       var pattern2 = /(\n)([A-Z"]|\d|\[B\]|\[I\]|\[IMG\])/g; 
       var pattern3 = /\[IMG alt="([^"]*)"/g; 
       var pattern4 = /\n/g; 
       var pattern5 = /(\[HEADING=2\]|\[LIST\]|\[\*\)|\[\/LIST\]|\[IMG\])/g; 
       var pattern6 = /\[\/?FONT(=.*?)?\]/g; 
       var pattern7 = /\[\/?COLOR(=.*?)?\]/g; 
       var pattern8 = /\[\/?INDENT(?:=\d\d?)?\]/g; 
       var replacedText = text.replace(pattern1, '[U][URL=$1[/URL][/U]'); 
       replacedText = replacedText.replace(pattern2, '$1\n$2'); 
       replacedText = replacedText.replace(pattern3, '\n[IMG alt="$1"'); 
       replacedText = replacedText.replace(pattern4, '\n\n'); 
       replacedText = replacedText.replace(pattern5, '\n$1'); 
       replacedText = replacedText.replace(pattern6, ''); 
       replacedText = replacedText.replace(pattern7, ''); 
       replacedText = replacedText.replace(pattern8, ''); 
       replacedText = replacedText.replace(/\n{4,}/g, '\n\n'); 
       replacedText = replacedText.replace(/\[U\]\[U\]\[URL=(.*?)\[\/URL\]\[\/U\]\[\/U\]/g, '[U][URL=$1[/URL][/U]'); 
       replacedText = replacedText.replace(/\[\/HEADING\]\n/g, '[/HEADING]'); 
       replacedText = replacedText.replace(/\[\/IMG\]\n/g, '[/IMG]'); 
       textarea.value = replacedText;
   });
})();
 
Last edited:

bnew

Veteran
Joined
Nov 1, 2015
Messages
54,839
Reputation
8,165
Daps
155,131
getting the hang of this , added a pattern for replacing \[\/?RIGHT\] & align="(left|right)" with nothing. these bookmarklets are what I always use to share an article on the coli. without it it's impossible to post or the content looks janky.

Code:
 javascript:(function() {   var textareas = document.querySelectorAll('textarea.input');
   textareas.forEach(function(textarea) {         var text = textarea.value;
         var pattern1 = /\[URL=(.*?)\[\/URL\]/g;
         var pattern2 = /(\n)([A-Z"]|\d|\[B\]|\[I\]|\[IMG\])/g;
         var pattern3 = /\[IMG alt="([^"]*)"/g;
         var pattern4 = /\n/g;
         var pattern5 = /(\[HEADING=2\]|\[LIST\]|\[\*\)|\[\/LIST\]|\[IMG\])/g;
         var pattern6 = /\[\/?FONT(=.*?)?\]/g;
         var pattern7 = /\[\/?COLOR(=.*?)?\]/g;
         var pattern8 = /\[\/?INDENT(?:=\d\d?)?\]/g;
         var pattern9 = /\[\/?RIGHT\]/g;
         var pattern10 = /align="(left|right)"/g;
         var replacedText = text.replace(pattern1, '[U][URL=$1[/URL][/U]');
         replacedText = replacedText.replace(pattern2, '$1\n$2');
         replacedText = replacedText.replace(pattern3, '\n[IMG alt="$1"');
         replacedText = replacedText.replace(pattern4, '\n\n');
         replacedText = replacedText.replace(pattern5, '\n$1');
         replacedText = replacedText.replace(pattern6, '');
         replacedText = replacedText.replace(pattern7, '');
         replacedText = replacedText.replace(pattern8, '');
         replacedText = replacedText.replace(pattern9, '');
         replacedText = replacedText.replace(pattern10, '');
         replacedText = replacedText.replace(/\n{4,}/g, '\n\n');
         replacedText = replacedText.replace(/\[U\]\[U\]\[URL=(.*?)\[\/URL\]\[\/U\]\[\/U\]/g, '[U][URL=$1[/URL][/U]');
         replacedText = replacedText.replace(/\[\/HEADING\]\n/g, '[/HEADING]');
         replacedText = replacedText.replace(/\[\/IMG\]\n/g, '[/IMG]');
         textarea.value = replacedText;
   });
 })();
 
Top