BEST ARTICLE

Best Article

Best Article

Blog Article

This is a short guide.
???? Step-by-Step Behavior
When you click the extension icon:

chrome.action.onClicked.addListener triggers.

Loads urls.txt → fetchTextFile('urls.txt')

Loads article.txt → fetchTextFile('article.txt')

Parses URLs:

parseUrls() splits lines, trims them, and removes blanks.

Loops through each URL:

Opens it in a new tab (inactive).

Waits until the tab finishes loading.

Spins content:

Extracts title and body from article.txt using regex.

Applies spin() to randomize the text inside {} blocks.

Injects and runs a script in the tab:

Clicks "Text" tab.

Fills in the title and body.

Clicks "Publish".

Waits up to 10 seconds for a "View your post" link.

Captures the published post URL.

After all URLs:

Opens results.html and sends published URLs via ?data=[].

???? Requirements to Make It Work
urls.txt and article.txt must be in the extension root (public or listed in web_accessible_resources).

Each target site must:

Contain expected input fields (#title, #content).

Use a "Publish" button labeled with publish or similar.

You must load the extension unpacked in Chrome.

Browser must allow popups (auto-tab creation).

results.html should work if accessed via:

chrome-extension://[EXT_ID]/results.html?data=["https://..."]
???? Potential Issues
If tab takes too long or errors, the publish link might not be found.

Some CMS editors may not match selector expectations.

Browser security might block cross-tab scripting if permissions are missing.

Download button issue may block result export (already addressed earlier).

a. Want a test-ready urls.txt + article.txt example to try locally?
b. Want to add retry logic if publishing fails for a URL?

You said:
a
ChatGPT said:
Here's a minimal test-ready example for both urls.txt and article.txt so you can verify everything works end-to-end:

✅ urls.txt
Place this in the root of your Chrome extension folder:

https://example.com/wp-admin/post-new.php
https://your-site.com/editor
Make sure these are actual CMS editors you can test against, like WordPress or similar that allow form autofill and publishing.

✅ article.txt
Title: Awesome Guide to Blogging
Body:
Welcome to this simple tutorial on how to optimize your website.
We will cover some key techniques you can use today.
✅ Place Both Files Here
background.js (already created)

results.html and results.js

urls.txt

article.txt

Add all to your extension folder

Load unpacked in Chrome

Then click the extension icon to trigger the whole process.

a. Want to add a "Preview Spin" button to test article.txt inside a popup?
b. Want to add logging of failed publish attempts for debugging?

No file chosenNo file chosen
ChatGPT can make mistakes. Check important info. See Cookie Preferences.

Report this page