Bookmarking question

Is there a way, in one click, to grab a webpage’s title and url, wrap them thusly [ext[ + title + | + url ]], and add that to the browser clipboard (in my case, Firefox)?

I tried TiddlyClip and TiddlyMarker out, but the former won’t install to Firefox (says the file is corrupt), and the latter gives error messages when saving a webpage as a file. I would like the above option instead. Grab and format the data with one click, then I can paste the data into a tiddler manually.

Never mind, I found the answer on the Internet: Create a bookmarket and add this as the url

javascript:(function() {  function copyToClipboard(text) {     if (window.clipboardData && window.clipboardData.setData) {         /*IE specific code path to prevent textarea being shown while dialog is visible.*/         return clipboardData.setData("Text", text);       } else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {         var textarea = document.createElement("textarea");         textarea.textContent = text;         textarea.style.position = "fixed";  /* Prevent scrolling to bottom of page in MS Edge.*/         document.body.appendChild(textarea);         textarea.select();         try {             return document.execCommand("copy");  /* Security exception may be thrown by some browsers.*/         } catch (ex) {             console.warn("Copy to clipboard failed.", ex);             return false;         } finally {             document.body.removeChild(textarea);         }     } }  var markdown = '[ext[' + document.title + '|' + window.location.href + ']]'; copyToClipboard(markdown); })();
3 Likes

I find AutoHotKey (AHK) good for those browser type tasks. Grabbing text, editing URLs, automating searches etc.

Dave Thanks for sharing back your answer;

  • If you found a good resource for constructing bookmarklets please share.

I love the potential power of bookmarklets, both inside and outside tiddlywiki and this is no exception, in part because it suggests other possibilities as well. For example constructing links for pasting in Discourse or other wikis, harvesting file urls browsing local directors from in the browser and all doing so while retaining the full information link and friendly name where applicable.

A few notes in case they are of assistance;

  • The form of link `[[pretty|url]]’ seems to be sufficient, searching for the details in tiddlywiki.com for the “ext” form is not helpful.
  • Is possible to do the same by another method wholly within tiddlywiki which I could do if you want, but then bookmarklets work across tab and urls.
  • I have noticed some changes in the interaction across Chrome and FireFox of late adding some complications to their utility.
  • By reverse engineering your bookmarklet, I see it primarily obtains document.title and window.location.href and recently I made my first javascript plugins/macros for tiddlywiki to get or set the window name, equivalent to the href “target”.

Speculation;

  • Altering your plugin to return a full htm “a” tag, href link including the target may be even more versatile; eg pseudo code;
    • <a href="window.location.href" target=" window.name "> document.title </a>
  • Or even hide document title behind a unicode character and have a tooltip.
    • <a title="document.title " href="window.location.href" target=" window.name ">🔗</a>

[Edited] Oh, and also better versions of the Permalink button.

1 Like

Thanks TW Tones! No, I don’t have a source on bookmarklets, I just Google searched and found that particular bookmarklet in a discussion somewhere.

2 Likes

Tiddlyclip is installed from here:

(https://github.com/buggyj/tiddlyclip/releases/download/0.1.8/tiddlyclip-0.1.8-fx.xpi)

It installs with firefox 103 on xubuntu

2 Likes

I’m glad you found a solution!

FWIW there have been a few discussions of “Bookmarklets” in the past.

I think it one of those things that could benefit everyone a lot IF we could articulate more how to best use them for TW. And also examine the structure of browser bookmarks.

Here is an older post in that direction: https://groups.google.com/g/tiddlywiki/c/37B5uhgbJwE/m/1rU9YBN6AwAJ?hl=en-GB

Just a comment, TT

2 Likes