Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript How to make a chrome extension to add a break tag after every para tag in a webpage?

rukuto

New Coder
I am not familiar with Javascript, HTML or CSS enough to be able to code a chrome extension. May I know how to go about it or if anyone can make one for me? Thank you. I will only be using it for personal use for reading novels online.
 
Solution
Been a while since I made a chrome extension, but lets see....

Create a folder and create two files: manifest.json and script.js
JSON:
{
  "name": "Paragraph breaker",
  "description": "This extension will add a line break after every paragraph",
  "version": "1.0",
  "manifest_version": 3,
  "content_scripts": [{
    "matches": ["https://www.example.com/*"],     //the website you want to add the line breaks to. If you want it to work on all websites use *://*/*
    "js": ["script.js"],
    "run_at": "document_end"
   }]
}
JavaScript:
var p = document.querySelectorAll("p");

p.forEach(function(item, index, arr) {
  var br = document.createElement("br");
  arr[index].parentNode.insertBefore(br, arr[index].nextSibling);
})

Now go to...
Been a while since I made a chrome extension, but lets see....

Create a folder and create two files: manifest.json and script.js
JSON:
{
  "name": "Paragraph breaker",
  "description": "This extension will add a line break after every paragraph",
  "version": "1.0",
  "manifest_version": 3,
  "content_scripts": [{
    "matches": ["https://www.example.com/*"],     //the website you want to add the line breaks to. If you want it to work on all websites use *://*/*
    "js": ["script.js"],
    "run_at": "document_end"
   }]
}
JavaScript:
var p = document.querySelectorAll("p");

p.forEach(function(item, index, arr) {
  var br = document.createElement("br");
  arr[index].parentNode.insertBefore(br, arr[index].nextSibling);
})

Now go to Chrome (or any chromium based browser) and go to extensions. Next turn on "developer mode" and click load unpacked. Go to your extension folder, and open it.
 
Last edited:
Solution
Hey, I tried this but it is not working.
I made a manifest.json and script.js file.
I also changed the name of the website. I want to use it for: novelbin.com
I load unpacked in chrome extensions and used the extension but it did not add br tags (or breaks in the text) in the webpage.
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom