1

I'm looking to create a bookmarklet that will modify any URLs that are created using the wordpress editor when creating a new post. This javascript/bookmarklet will add a string of code such as ?=2324 after any URL found in the post. a link to google.com will become google.com?=2324. The element ID for the form is textarea#content.wp-editor-area.

Is this possible?

1
  • when you mean url, you mean www.google.com or <a href="www.google.com" /> ? Commented Jul 9, 2012 at 19:37

1 Answer 1

2

First, add any bookmark. Then right-click on it and click on properties. Specify a name.

Then for the url, write:

javascript:var toChange=document.getElementById("content");var re=/("|')https?:\/\/*("|')/gi;toChange.value=toChange.replace(re,function($0){return $0+"?=234";});void(0)

If there is an error, tell it to me.

Sign up to request clarification or add additional context in comments.

8 Comments

That is the concept i need but the bookmarklet needs to actually edit the hyperlinks in the WYSIWIG editor of wordpress. Like a find and replace. Then once the post is saved, it can be viewed and all hyperlinks will have ?=2324 added to them. Thank you thus far!
I don't know a lot wordpress, maybe if you describe me how it is and the id of the textarea...
wordpress uses a WYSYWIG editor. See screenshot i.imgur.com/iy2RY.png. An ideal bookmarklet would find locate the URL in the WYSIWIG editor as http://* and append the =?232 to the URL.
does not work as a bookmarklet either. same error in console.
@user1512806 Is the WYSIWIG in an iframe?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.