Create Discourse Bookmarklet and redirect current page to another site

If you are using Discourse as a place to collect resources you find online, you might like these bookmarklets.

To use them, create a bookmark (I put them on my browser Bookmarks Bar), then right-click and edit the bookmark, copy one of the javascript blocks below, and paste it in the URL field.

Use these blocks to configure the code with your forum URL and preferred category.

These control the size of the pop-up window if you use one of those

Select your preferred action

New window, URL in title


New window: title from page title, selected text and URL in the topic body


Same Window: title from page title, selected text and URL in the topic body


New tab: title from page title, selected text and URL in the topic body


How to use on Android

To make this work on android, edit the url of the current page and type the name of your bookmark and select it from the list.

Visit current path on a different hostname

This is useful when checking how a production site’s URLs work on a staging server. For example, I’m working on a new web site, with this, I can go to each page on my site, click this link, and see what that page does on my test site.

Enter the domain you want to redirect to in the field below and then copy/paste the javascript into your bookmark.

Visit current path on =url=

Paste into a bookmark url

javascript:(function(){var a=window,b=document,c=encodeURIComponent,\/\/.*?\//,'=url='),"_add_to_discourse");a.setTimeout(function(){d.focus()},300)})();

Following How to enter newline character in bookmarklet JavaScript - Stack Overflow

Consider re-writing something like this:

javascript:(function() {
    var today = new Date();
    var url = '';
    var to = '';
    var subject = '【weather report】【' + today.getFullYear() + '-' + ('00' + (today.getMonth() + 1)).slice(-2) + '-' + ('00' + today.getDate()).slice(-2) + ' bar】 email from bookmarklet';
    var body1 = 'Hi,\n\nThis is Kim Kardashian.\nIt\'s sunny today.\n\ndate:';
    var targetDate = ' ' + today.getFullYear() + '-' + ('00' + (today.getMonth() + 1)).slice(-2) + '-' + ('00' + today.getDate()).slice(-2);
    var body2 = '\nName: Kim Kardashian\n';
    var body3 = '\nBest Regards,';
    url += '&to=' + encodeURIComponent(to) + '&su=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(body1 + targetDate + body2 + body3);;