bnew

Veteran
Joined
Nov 1, 2015
Messages
58,600
Reputation
8,651
Daps
162,540
so fix formatting of html code


Here's a change log in layman's terms from the initial code to the updated code, with the updated code appended: Version 1: Initial Code
  • The initial code was designed to format text within a textarea element on a webpage.
  • It replaced URLs with a specific format, added newlines before certain characters, and removed unnecessary tags.
  • It also removed duplicate newlines and improved the formatting of headings and images.
Version 2: Updated Code
  • **Fixed issue with characters∗∗:Theupdatedcodereplaced‘characters**:Theupdatedcodereplaced`characters∗∗:Theupdatedcodereplaced‘ characters with the correct brackets (‘and‘`and`‘and‘`) to fix a formatting issue.
  • Improved newline handling: The code now adds newlines before specific characters, such as headings and images, to improve readability.
  • Added support for math notation: The code now replaces text enclosed in double dollar signs ($$...$$) with LaTeX-style math notation ($$$1$$).
  • Improved paragraph formatting: The code now adds newlines between paragraphs to improve readability.
  • Added support for quote tags: The code now wraps text enclosed in
    tags in and tags to improve formatting.
  • Removed unnecessary patterns: The code removed some unnecessary patterns, such as pattern8, to simplify the formatting process.
  • Improved code organization: The code is now more organized, with each pattern and replacement clearly defined and separated.
Changes to Patterns
  • pattern1: Updated to match URLs with the correct brackets ($$ and $$).
  • pattern2: Updated to add newlines before specific characters, such as headings and images.
  • pattern3: Updated to add newlines before images with alt text.
  • pattern4: Updated to replace newlines with two newlines.
  • pattern5: Updated to add newlines before headings, lists, and images.
  • pattern6 and pattern7: Removed, as they are no longer necessary.
  • mathPattern: Added to replace text enclosed in double dollar signs with LaTeX-style math notation.
  • paragraphPattern: Added to add newlines between paragraphs.
  • quotePattern: Added to wrap text enclosed in
    tags in and tags.
Code:
javascript
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 = /\$\$\/IMG$$([A-Za-z0-9])/g;
    var pattern9 = /\n{2,}/g;

    var mathPattern = /\$\$(.*?)\$\$/g;

    var paragraphPattern = /([^\n])\n([A-Z0-9])/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, ']\n[/IMG]$1');
    replacedText = replacedText.replace(pattern9, '\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]');

    replacedText = replacedText.replace(mathPattern, '\$$$1\$$');

    replacedText = replacedText.replace(paragraphPattern, '$1\n\n$2');
   
    var quotePattern = /$$QUOTE$$(?:.*?\n)*?(.*?)$$\/QUOTE$$/gs;
    replacedText = replacedText.replace(quotePattern, '[QUOTE][SIZE=4]$1[/SIZE][/QUOTE]');

    textarea.value = replacedText;
  });
})();
 

bnew

Veteran
Joined
Nov 1, 2015
Messages
58,600
Reputation
8,651
Daps
162,540
To ensure that the script does not replace the same URL tags multiple times (if they've already been wrapped with [U]), we can modify the replacement logic to only apply the [U] wrapping if it hasn’t been applied already. One way to do this is by adding a condition to check if the [U] tags are already present.


Here’s an updated version of the code to address that:

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

    var mathPattern = /\$\$(.*?)\$\$/g;

    var paragraphPattern = /([^\n])\n([A-Z0-9])/g;

    
    var replacedText = text.replace(pattern1, function(match, url) {
      
      if (!/\[U\]/.test(match)) {
        return `[U][URL]${url}[/URL][/U]`;
      }
      return match;
    });
    
    replacedText = replacedText.replace(pattern2, function(match, url, innerText) {
      
      if (!/\[U\]/.test(match)) {
        return `[U][URL=${url}]${innerText}[/URL][/U]`;
      }
      return match;
    });

    replacedText = replacedText.replace(pattern3, '$1\n$2');
    replacedText = replacedText.replace(pattern4, '\n[IMG alt="$1"');
    replacedText = replacedText.replace(pattern5, '\n\n');
    replacedText = replacedText.replace(pattern6, '');
    replacedText = replacedText.replace(pattern7, '');
    replacedText = replacedText.replace(pattern8, ']\n[/IMG]$1');
    replacedText = replacedText.replace(pattern10, '\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]');

    replacedText = replacedText.replace(mathPattern, '\\[$1\\]');

    replacedText = replacedText.replace(paragraphPattern, '$1\n\n$2');
    
    var quotePattern = /\[QUOTE\](?:.*?\n)*?(.*?)\[\/QUOTE\]/gs;
    replacedText = replacedText.replace(quotePattern, '[QUOTE][SIZE=4]$1[/SIZE][/QUOTE]');

    textarea.value = replacedText;
  });
})();


Key Changes:​


  1. Pattern Matching for [U][/B]: In the replacement functions for both pattern1 (the [URL]...[/URL] pattern) and pattern2 (the [URL=]...[/URL] pattern), I’ve added a check to see if the text is already wrapped in [U] using the regular expression /\[U\]/. If the text is already wrapped in [U], it will skip the wrapping and leave the original match as is.
    • This avoids wrapping [URL] tags multiple times.
    [*]Replacement Functions: I used replace() with a callback function, which checks each match and ensures that [U] tags are only added if not already present.



Example Input:

Code:
🛰️ Paper: [URL]https://arxiv.org/abs/2412.10360[/URL]
🌌 Website: [URL]https://apollo-lmms.github.io[/URL]



Expected Output:

Code:
🛰️ Paper: [U][URL]https://arxiv.org/abs/2412.10360[/URL][/U]
🌌 Website: [U][URL]https://apollo-lmms.github.io[/URL][/U]



Example After Running the Script Twice:


If you run the script on the same text twice, it will not apply the [U] tags again, ensuring that the result remains unchanged after the first execution.
 

bnew

Veteran
Joined
Nov 1, 2015
Messages
58,600
Reputation
8,651
Daps
162,540
updated the bluesky post extract bookmarklet to get playlist urls for videos moree reliably since the old one only retrieved one playlist url no matter how many vidos were in a thread.

*NOTE: quoted posts not working.. :(

What Does This Code Do?​

This code is a bookmarklet designed to work on Bluesky (BSky) posts and threads. When you run it on a Bluesky thread or profile page, it performs several tasks to extract and format the content of the posts in a user-friendly way. Here's a detailed breakdown of its functionality:

1. Prompts You to Specify How Many Posts to Extract​

- When you click the bookmarklet, it shows a pop-up window with a calculator-like interface.
- You can enter the number of posts you want to extract (e.g., 5, 10, or 20).
- If you enter an invalid number (like 0 or a negative number), it will ask you to try again.

2. Extracts Posts from the Thread​

- After you specify the number of posts, the script scans the Bluesky thread or profile page.
- It identifies all the posts made by the original author of the thread (ignoring replies from other users unless specified otherwise).
- It collects the following details for each post:
  • Author's username (prefixed with a 🇺 emoji for visual distinction).
  • Post content (the text of the post).
  • Embedded links (e.g., playlist links, video links, or image links).
  • Quoted posts (if the post references or quotes another post, it includes the quoted content).
  • Images (if the post contains images, it adds them as clickable links).

3. Fetches Additional Data from Bluesky's API​

- For each post, the script makes a call to Bluesky's public API to fetch additional details, such as:
  • Embedded media (e.g., playlists, videos, or images).
  • Post metadata (e.g., unique post IDs and URLs).
- If the post contains a playlist, video, or image, the script appends the link to the post's text.

4. Formats the Extracted Content​

- The script organizes the extracted posts into a structured and readable format:
  • Each post is numbered (e.g., "1/5", "2/5") to indicate its position in the thread.
  • The author's username is displayed with the 🇺 emoji (e.g., "🇺 username").
  • Links, quoted posts, and images are clearly marked and formatted for easy reading.
  • The entire thread is wrapped in spoiler tags (e.g., [SPOILER="thread continued"]) to make it compact and easy to navigate.

5. Copies the Formatted Text to Your Clipboard​

- Once the script finishes extracting and formatting the posts, it automatically copies the entire formatted text to your clipboard.
- You can then paste the text anywhere (e.g., a forum, document, or chat) without needing to manually copy and format each post.

6. Shows a Notification​

- After copying the text, the script displays a small notification at the bottom-left corner of the screen to let you know how many posts were copied (e.g., "Copied: 5 posts").
- The notification fades away after a few seconds.

7. Handles Errors Gracefully​

- If something goes wrong (e.g., the script can't find posts or fetch data from the API), it will log the error in the browser's console and continue processing the remaining posts.
- This ensures that the script doesn't break completely if it encounters an issue.

What Does the Final Output Look Like?​

Here’s an example of what the formatted output might look like when you paste it:

Code:
https://bsky.app/profile/username/post/12345

[SPOILER="thread continued"]
https://bsky.app/profile/username/post/12346
https://bsky.app/profile/username/post/12347
[/SPOILER]

[SPOILER="full text & large images"]

1/3
🇺 username
This is the first post in the thread.
[U][URL]https://example.com/playlist[/URL][/U]

2/3
🇺 username
This is the second post.
[Quoted post]
🇺 another_user
https://bsky.app/profile/another_user/post/67890
This is the quoted post content.

3/3
🇺 username
This is the third post with an image.
[img]https://example.com/image.jpg[/img]

[COLOR=rgb(184,49,47)][B][SIZE=5]To post tweets in this format, more info here: [URL]https://www.thecoli.com/threads/tips-and-tricks-for-posting-the-coli-megathread.984734/post-52211196[/URL][/SIZE][/B][/COLOR]
[/SPOILER]

Why Is This Useful?​

- Saves Time: Instead of manually copying and formatting each post, this script automates the process.
- Preserves Context: It includes all relevant details (e.g., links, quoted posts, images) in a structured format.
- Easy Sharing: The formatted text is ready to be pasted into forums, blogs, or other platforms that support BBCode or similar formatting.
- Customizable: You can choose how many posts to extract, making it flexible for both short and long threads.

Who Would Use This?​

- Forum Users: People who want to share Bluesky threads on forums that use BBCode formatting.
- Content Creators: Bloggers or writers who want to archive or reference Bluesky posts in their work.
- Casual Users: Anyone who wants to save or share Bluesky threads in a clean, readable format.

Conclusion​

In summary, this script is a powerful tool for extracting, formatting, and sharing Bluesky posts and threads with minimal effort. It’s designed to make your life easier when dealing with long or complex threads! Let me know if you have further questions or need additional features. 😊



v3.6

DeepSeek-V3 fixed the issue :in one shot :wow:

protip: when posting to the coli an output of more than 6,000 characters switch to bbcode editor so the post goes through without any 500 interval error message appearing.
 
Last edited:

bnew

Veteran
Joined
Nov 1, 2015
Messages
58,600
Reputation
8,651
Daps
162,540
made a threads.net bookmarklet that basically and ALPHA version since i have to figure out how to extract images properly. this is basically quick conversion from nitter bookmarklet that chains posts and only shares post links by main author.




This code is a bookmarklet—a small piece of JavaScript code that you can run in your browser to perform specific tasks on a webpage. In this case, the bookmarklet is designed to extract and format posts from a Threads.net page (a social media platform) into a structured, easy-to-read format. Here's a detailed breakdown of what it does, explained in simple terms:

What Does the Code Do?

  1. Finds All Posts on the Page:
    • The code looks for all the posts on the Threads.net page. Each post is identified by a specific HTML structure ([data-pressable-container="true"]).
  2. Extracts the Main Author's Username:
    • It identifies the username of the main author (the person who created the first post) by looking at the URL of the first post. For example, if the URL is https://threads.net/@theluigion/post/12345, it extracts theluigion as the username.
  3. Collects Post Data:
    • For each post, the code extracts:
      • Post Content: The text of the post.
      • Post Link: The URL of the post.
      • Author's Username: The username of the person who created the post (extracted from the post URL).
      • Quoted Posts: If the post includes a quoted post (a reference to another post), it extracts the quoted text and link.
      • Images and Videos: Any images or videos embedded in the post.
      • External Links: Links to external websites (e.g., https://www.syracuse.com).
  4. Formats the Data:
    • The extracted data is formatted into a structured output using BBCode (a markup language often used in forums). For example:
      • Post text is displayed as plain text.
      • Links are wrapped in [URL] tags.
      • Images are wrapped in [img] tags.
      • Quoted posts are labeled and included in the output.
  5. Groups Posts into Threads:
    • If there are multiple posts in a thread, the code groups them together and separates them into sections:
      • Thread Continued: Links to other posts in the thread by the main author.
      • Full Text & Large Images: The full content of all posts, including text, images, and videos.
  6. Copies the Output to the Clipboard:
    • Once the data is extracted and formatted, the code copies the entire output to your clipboard. You can then paste it wherever you need (e.g., into a forum or document).
  7. Shows a Notification:
    • A small notification pops up in the bottom-left corner of the screen to let you know how many posts were copied.

Why Is This Useful?​

  • Saves Time: Instead of manually copying and formatting posts, this tool does it automatically.
  • Preserves Structure: It keeps the structure of the thread intact, including quoted posts, images, and links.
  • Easy Sharing: The formatted output is ready to be shared on forums or other platforms that support BBCode.

Step-by-Step Example​

Let’s say you’re viewing a Threads.net thread with the following posts:
  1. Post 1 by @theluigion:
    • Text: "Check out this article!"
    • Link: https://threads.net/@theluigion/post/12345
    • External Link: https://www.syracuse.com/article
  2. Post 2 by @syracusedotcom:
    • Text: "Here's a follow-up to the article."
    • Link: https://threads.net/@syracusedotcom/post/67890
    • Image: https://example.com/image.jpg
When you run the bookmarklet, it will:
  1. Extract the content of both posts.
  2. Format the output like this:

    Code:
    https://threads.net/@theluigion/post/12345
    [SPOILER="thread continued"]
    https://threads.net/@syracusedotcom/post/67890
    [/SPOILER]
    [SPOILER="full text & large images"]
    1/2
    @theluigion
    Check out this article!
    [U][URL]https://www.syracuse.com/article[/URL][/U]
    
    2/2
    @syracusedotcom
    Here's a follow-up to the article.
    [img]https://example.com/image.jpg[/img]
    [/SPOILER]
  3. Copy this formatted text to your clipboard.

Key Features

  • Handles Multiple Authors: It correctly identifies and attributes posts to different authors.
  • Extracts Media: It includes images and videos in the output.
  • Filters Links: It only includes external links and excludes internal Threads.net links.
  • Ignores Favicons: It skips small icons (favicons) that are not part of the main content.

How to Use It

  1. Copy the bookmarklet code.
  2. Create a new bookmark in your browser and paste the code into the URL field.
  3. Open a Threads.net thread.
  4. Click the bookmarklet to run it.
  5. The formatted output will be copied to your clipboard, and a notification will confirm the action.

Who Is This For?

  • Social Media Users: If you want to share Threads.net posts on other platforms.
  • Forum Users: If you need to post Threads.net content in BBCode format.
  • Content Creators: If you want to archive or repurpose Threads.net posts.

In summary, this bookmarklet is a handy tool for automatically extracting and formatting Threads.net posts into a clean, structured format that’s easy to share or archive. It saves you time and ensures that all the important details (text, links, images, and videos) are preserved.

 

bnew

Veteran
Joined
Nov 1, 2015
Messages
58,600
Reputation
8,651
Daps
162,540
To include **all post URLs** in the `[SPOILER="thread continued"]` section (not just those by the main author), we need to modify the filtering logic. Here's the updated bookmarklet code:

---

### **Updated Bookmarklet (Includes All Post URLs in Threads Continued Spoiler)**


---

### **Key Changes**
1. **Include All Post URLs**:
- The `[SPOILER="thread continued"]` section now includes **all post URLs** from the thread, regardless of the author.
- This is done by removing the filtering logic that previously restricted it to only the main author's posts.

2. **Output Format**:
- The `[SPOILER="thread continued"]` section will now list all post URLs in the thread.



### **Example Output**
For a thread with the following posts:
1. **Post 1** by `@theluigion`:
- URL: `https://threads.net/@theluigion/post/12345`
2. **Post 2** by `@syracusedotcom`:
- URL: `https://threads.net/@syracusedotcom/post/67890`
3. **Post 3** by `@sarahrain68`:
- URL: `https://threads.net/@sarahrain68/post/98765`

The output will look like this:
Code:
https://threads.net/@theluigion/post/12345
[SPOILER="thread continued"]
https://threads.net/@syracusedotcom/post/67890
https://threads.net/@sarahrain68/post/98765
[/SPOILER]
[SPOILER="full text & large images"]
1/3
@theluigion
Check out this article!
[U][URL]https://www.syracuse.com/article[/URL][/U]

2/3
@syracusedotcom
Here's a follow-up to the article.
[img]https://example.com/image.jpg[/img]

3/3
@sarahrain68
Great discussion!
[/SPOILER]

---

### **How to Use**
1. Copy the updated bookmarklet code.
2. Create a new bookmark in your browser and paste the code into the URL field.
3. Open a Threads.net thread.
4. Click the bookmarklet to run it.
5. The formatted output will be copied to your clipboard, and a notification will confirm the action.

---

Let me know if you need further adjustments!

 

bnew

Veteran
Joined
Nov 1, 2015
Messages
58,600
Reputation
8,651
Daps
162,540
To modify the bookmarklet so that it **only includes posts and post URLs by the main author** in the `[SPOILER="thread continued"]` section, we need to filter the posts based on the author's username. Here's the updated code:

---

### **Key Changes**
1. **Filter Posts by Main Author**:
- The `[SPOILER="thread continued"]` section now only includes posts and post URLs by the **main author** (the author of the first post).
- This is done by filtering `userPosts` to include only those links where the post author matches `mainUsername`.

2. **Output Format**:
- Only posts and URLs by the main author are included in the `[SPOILER="thread continued"]` section.

---

### **Example Output**
For a thread with the following posts:
1. **Post 1** by `@theluigion`:
- URL: `https://threads.net/@theluigion/post/12345`
2. **Post 2** by `@syracusedotcom`:
- URL: `https://threads.net/@syracusedotcom/post/67890`
3. **Post 3** by `@theluigion`:
- URL: `https://threads.net/@theluigion/post/98765`

The output will look like this:
Code:
https://threads.net/@theluigion/post/12345
[SPOILER="thread continued"]
https://threads.net/@theluigion/post/98765
[/SPOILER]
[SPOILER="full text & large images"]
1/2
@theluigion
Check out this article!
[U][URL]https://www.syracuse.com/article[/URL][/U]

2/2
@theluigion
Here's a follow-up to the article.
[img]https://example.com/image.jpg[/img]
[/SPOILER]

---

### **How to Use**
1. Copy the updated bookmarklet code.
2. Create a new bookmark in your browser and paste the code into the URL field.
3. Open a Threads.net thread.
4. Click the bookmarklet to run it.
5. The formatted output will be copied to your clipboard, and a notification will confirm the action.

---

Let me know if you need further adjustments!


 

bnew

Veteran
Joined
Nov 1, 2015
Messages
58,600
Reputation
8,651
Daps
162,540
amended with chatgpt 4o-mini.

fixes lines and formatting when posting articles. must use BBcode editor.



Sure! Here’s a detailed summary of what the code does, broken down into simpler terms:

Overview​


This code is a bookmarklet written in JavaScript. When executed in a web browser, it looks for specific text areas on a webpage and modifies the text inside them according to certain rules. The primary purpose is to clean up and reformat text that uses a specific markup style, which appears to be related to forum or content management systems.

Detailed Breakdown​


  1. Selecting Text Areas:
    • The code starts by finding all <textarea> elements on the page that have a class of input. A <textarea> is a form field where users can enter multi-line text.
  2. Looping Through Each Text Area:
    • For each text area found, the code gets the current text inside that area. This is where the modifications will take place.
  3. Defining Patterns:
    • The code uses regular expressions (regex) to identify specific patterns in the text. Regular expressions are like search patterns that help find specific strings or formats in the text. Here are the main patterns used:
      • URL Pattern: Looks for links in a certain format (e.g., [URL='http://.../']).
      • Image Alt Text Pattern: Finds image tags that specify alternative text.
      • Empty List Pattern: Identifies
        • blocks that contain only list items (
        • ) or are empty.
        • List Item Pattern: Looks for list items followed by newlines to ensure they stay on the same line.
        • Formatting Tags: Identifies various tags like headings and lists that need specific formatting.
      • Text Replacement:
        • The code replaces certain parts of the text according to the patterns defined. For example:
        • It reformats URL tags to include underline formatting.
        • It ensures that list items have their content right after them on the same line.
        • It removes any empty list blocks that don't contain any content.
        • It cleans up formatting tags that are not necessary.
      • Cleaning Up Line Spacing:
        • After making the replacements, the code consolidates multiple empty lines into a maximum of two. This helps keep the text neat and readable.
      • Final Formatting:
        • The code trims any extra spaces from the start and end of each line and removes any completely empty lines.
      • Updating the Text Area:
        • Finally, the modified text is placed back into the original text area, replacing the old content with the cleaned-up version.

        Conclusion​


        In summary, this code is a helpful tool for cleaning and formatting text in specific input fields on a webpage. It makes sure that the text follows a consistent style, maintains proper line spacing, and removes any unnecessary or empty elements. This is particularly useful for users who are editing posts or messages that use a certain markup language. It helps ensure that the final output looks neat and professional, making it easier for readers to understand.

 
Last edited:

bnew

Veteran
Joined
Nov 1, 2015
Messages
58,600
Reputation
8,651
Daps
162,540
how to post , share , upload a worldstar / worldstarhiphop video since the url format changed on the world start site and they re no longer using urls that look like http://m.worldstarhiphop.com/video.php?v=wshh56rPQ87jOnQQvAm5.


This code is a bookmarklet, which is a small piece of JavaScript that can be saved as a bookmark in your web browser. Here’s what it does in simple terms:

What the Code Does​

  1. Extracts a Unique ID:
    • When you click the bookmarklet, it searches through the HTML code of the current webpage for a specific piece of information called videoUniqueId.
    • This ID is usually hidden within the webpage's scripts and is used to identify a particular video.
  2. Generates URLs:
    • Once it finds the videoUniqueId, it uses this ID to create two different types of URLs:
      • A short URL in the format [MEDIA=wshh]ID[/MEDIA].
      • A full URL in the format https://worldstarhiphop.com/embed/ID.
  3. Toggles Between URL Formats:
    • The code has a toggle switch (useMediaTag) that determines whether to use the short [MEDIA=wshh]ID[/MEDIA] format or the full URL format.
    • By default, it uses the short format, but you can change this by setting useMediaTag to false.
  4. Copies Text to Clipboard:
    • After generating the appropriate URL, it copies this URL along with the current webpage's address (URL) to your clipboard.
    • This means you can easily paste these URLs elsewhere.
  5. Displays a Toast Notification:
    • After copying the text to your clipboard, it shows a small pop-up message (toast notification) on your screen indicating what has been copied.
    • This notification includes both the generated URL and the current webpage's address.

Step-by-Step Breakdown​

  1. Search for Video Unique ID
    • The code looks through all script tags on the webpage for a specific string containing videoUniqueId.
    • If found, it extracts the ID number.
  2. Generate URLs
    • If useMediaTag is true, it creates a short URL like [MEDIA=wshh]12345[/MEDIA].
    • If useMediaTag is false, it creates a full URL like https://worldstarhiphop.com/embed/12345.
  3. Combine Text for Clipboard
    • It combines both the generated URL and the current webpage's address into one string.
    • For example:

      Code:
      [MEDIA=wshh]12345[/MEDIA]
      https://example.com/current-page
  4. Copy Text to Clipboard
    • It attempts to copy this combined text into your system's clipboard.
  5. Show Toast Notification
    • After copying, it displays a pop-up message showing what was copied.

Example Scenario​

  • You are on a webpage with a video from WorldStarHipHop.
  • You click the bookmarklet.
  • The script finds the videoUniqueId (e.g., 12345).
  • If using default settings (useMediaTag = true), it generates [MEDIA=wshh]12345[/MEDIA].
  • It also captures the current webpage's URL (e.g., https://example.com/current-page).
  • It copies both lines of text to your clipboard.
  • A toast notification appears showing:

Code:
Copied:
[MEDIA=wshh]12345[/MEDIA]
https://example.com/current-page


This way, you can easily share or use these URLs without having to manually copy them from different parts of the webpage.



userscript:






Instructions on manually getting the url you need to be able to share on the forum.

Markdown (GitHub flavored):
Here are the simple steps to extract the `videoUniqueId` from a WorldStarHipHop video page and construct the necessary URLs manually:


### Step-by-Step Instructions


#### 1. Open the Video Page

- Go to the WorldStarHipHop video page you want to extract the `videoUniqueId` from.


#### 2. View Page Source

- Right-click on the webpage and select "View Page Source" or press `Ctrl + U` (Windows) or `Cmd + Option + U` (Mac) to open the page source.


#### 3. Find the Script Tags

- In the page source, press `Ctrl + F` (Windows) or `Cmd + F` (Mac) to open the search bar.

- Type "videoUniqueId" in the search bar and press Enter.


#### 4. Extract the Video Unique ID

- Look for a line that looks something like this:

  ```javascript

  "videoUniqueId": 12345,

  ```

  The number after `"videoUniqueId":` is your unique ID (e.g., `12345`).


#### 5. Construct the URLs


##### Media Tag URL

- If you want to use the media tag format, construct it like this:

  ```

  [MEDIA=wshh]12345[/MEDIA]

  ```


##### Full Embed URL

- If you want to use the full embed URL format, construct it like this:

  ```

  https://worldstarhiphop.com/embed/12345

  ```


#### 6. Copy and Use

- Copy either of these constructed URLs and use them as needed.


### Example


Let's say you found this line in the page source:

```javascript

"videoUniqueId": 67890,

```


You would then construct your URLs as follows:


##### Media Tag URL

```

[MEDIA=wshh]67890[/MEDIA]

```


##### Full Embed URL

```

https://worldstarhiphop.com/embed/67890

```


### Additional Tips


- Make sure you are on a WorldStarHipHop video page when doing this.

- The `videoUniqueId` should be a number.

- If you can't find `"videoUniqueId"` in the page source, it might be hidden or not available on that specific page.


By following these steps, you can manually extract and construct the necessary URLs for any WorldStarHipHop video.
 
Last edited:
Top