DirkDiggler
DirkDiggler

Reputation: 84

javascript bookmarklet to modify HTML Source in wordpress editor

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?

Upvotes: 1

Views: 547

Answers (1)

Alexandre Khoury
Alexandre Khoury

Reputation: 4012

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.

Upvotes: 2

Related Questions