Bookmarklets, Just in Time install, Windows work flow and Timimi

This 15min Video is a quick demonstration, of a few of the techniques I use for my daily use of tiddlywiki. Not exactly a “how too” but a demo.

Please open in YouTube to see its full length of 14 mins.

4 Likes

Thank you, Anthony, for that video. I learned things! :slight_smile:

Can you give an example of one of your bookmarklets, like VisitorV2? What is the URL content of that bookmarklet?

Visitorv2vbookmarklet simply applies a dozen or so tiddlers to the current wiki. It installs some macros, buttons and a set of visibility tiddlers that show buttons.

It contains the tool to make itself ie the visitorv2 bookmarklet so you could poke around and do it for yourself but that tool is not ready for general release.

To identify tiddlers to include you can create a list of recently changed tiddlers and review that list after applying various settings to your wiki.

I will see if I can share something in the next week.

2 Likes

Here is a tiddler containing the VisitorV2 plugin. Import to a wiki. VisitorV2.json (20.5 KB)

  • Click it to apply to the current wiki
  • Drag and drop it to your bookmarks to reuse it on any wiki try tiddlywiki.com where I always use it.
  • After using it, select regenerate bookmarklet inside the VisitorV2-bookmarklet tiddler to see what is included.
    • Note: The bookmarklet facility installed is buggy.
  • See VisitorV2-bookmarklet and its bookmarklet field for the URI content, but basically it contains the tiddlers listed when you select "regenerate bookmarklet ".

I have continued my journey of making use of, and developing features with Bookmarklets, and it is starting to bare substantial fruits. Thus I thought I would reopen this aptly named discussion.

Caution: Bookmarklets with tiddler payloads can install or replace tiddlers without regard to previous content. Like usual be careful, test and have backups.

Here are some related notes;

Visit This Bookmarklets in TiddlyWiki site to make use of tools and features including;

  • Creating bookmarklets;
    • Drag any tiddler to your bookmarklets/ Favorites to install that tiddler in any wiki with a click of the bookmarklet.
    • Use advanced search filter to generate a list of tiddlers and again you can drag this to your bookmarklets, and click will install all tiddlers.
    • Drop your own tiddler(s) on the Bookmarklets site to easily create you own for use in your wikis.
  • Generate a bookmarklet tiddler (tentative standard, open to revision) which you can use to;
    • Share Bookmarklets just as you do tiddlers
    • Save bookmarklets in tiddlers to maintain a repository of bookmarklets out side your browser bookmarks/favourites.
  • Do search talk.tiddlywiki for topics on Bookmarklets as others have published interesting applications of bookmarklets.

Perhaps one of the most common uses of Bookmarklets is applying settings or preferences to any wiki, including using two to toggle between two states (at least until some of the innovations I am working on are available).

  • Go to the Bookmarklets site
  • Find a setting you want a bookmarklet to apply
  • Set or toggle that setting eg; go to Control Panel > Appearance > Theme tweaks > Sidebar layout and set or reset the value Fluid story, fixed sidebar or Fixed story, fluid sidebar, set it to the value you want in your bookmarklet.
  • Now look in the edit recent or edit Recent $:/ tabs and/or behind the state and temp tiddlers view.
    • Here you will find the tiddler that changed when you change the setting, click to open it.
    • Now drag the large bookmark icon on the tiddler to your bookmarks and favorites, give it a suitable name, or place it in an appropriate folder.
  • To add more than one tiddler to a bookmarklet, identify the tiddlers and use the advanced search > filters tab to list the tiddler(s), and drag the bookmarklet icon to your bookmarks, give it a suitable name, or place it in an appropriate folder.
    • To make a bookmarklet tiddler to share with others click the bookmarklet icon containing the +
      • Rename the tiddler to a suitable title, you can now export this tiddler and share with others or drop on another wiki.
      • Edit the description field explaining this bookmarklet
  • In any wiki containing a bookmarklet tiddler you can drag the link to your bookmarks, or just click the link in the tiddler to make it happen.

Subsequent replies here will share more…

1 Like

What is special about bookmarklet tiddlers?

If you create a bookmarklet tiddler you can export it and share it in the forum, but there is another quality to it;

  • Inside the bookmarklet tiddler in the link to drag to you bookmarklets, however it can be clicked to action the bookmarklet without using it from the bookmarklets.
  • This is in effect a small fragment of javascript you can run in your wiki without first having to install a plugin.
    • Thus it can be used on read only sites
    • There are limitations to what It can do, so I do not think it is a security risk.
  • The tools currently on the Bookmarklets site are primarily about sharing tiddler payloads in Bookmarklets, however there are a range of other ways to use the bookmarklets and javascript “fragments” for example;
  • In the near future I will further develop the Bookmarklet tools to assist in creating these other types of bookmarklets.

Collaborators welcome!

1 Like

A vero.

I do think your on-going bookmarklet thing is neat!

I kinda suspect it needs a few more end use cases to convince idiots like me?

Caro @TW_Tones, I just wonder HOW we can support this initiative to better ADD (make available) the mini-javascript-bookmarks-inter-fuels TW cherishes already?

Consistently. For an/ever…yone.

Just a comment.
Dimmi
TT

Just got around to asking ChatGPT to generate bookmarklets and it works better than I could imagine.

I now have after 15minutes work a bookmarklet that will set the current/tab or window name to the domain name, the file name is on file:// and to the last folder name if the filename was index.html and now an option to clear the window name is already set.

To paraphrase worf from start trek “Its a good time to be alive”

<a href="javascript:(function(){function getFilenameFromUrl(url){var path=new URL(url).pathname;return path.substring(path.lastIndexOf('/')+1);}function getLastFolderFromUrl(url){var path=new URL(url).pathname;var pathArray=path.split('/').filter(item=>item.length>0);return pathArray.length>1?pathArray[pathArray.length-2]:'';}if(window.name){if(confirm('Window name already set: '+window.name+'. Do you want to clear the window name?')){window.name='';alert('Window name cleared.');}else{alert('Window name not cleared.');}}else{var url=document.location.href;var isFileUrl=url.startsWith('file://');var identifier;if(isFileUrl){var filename=getFilenameFromUrl(url);identifier=(filename==='index.html')?getLastFolderFromUrl(url):filename;}else{identifier=document.location.hostname;}window.name=identifier;alert('Window name set to: '+identifier);}})();">Set or Clear Window Name</a>

Will talk.tiddlywiki honor the link? Set or Clear Window Name No it will not work directly from here.

Past the above code into a tiddler on any wiki and see the result.

[Edited] I have taken this a big step further and that is to maintain the list of named windows in local storage to keep window names unique. I am now trying to see if it can prompt for a window name to be entered if not unique. OMG :nerd_face: ::cupid:

  • Got it working
3 Likes

Wonderful @TW_Tones
TW has this unique feature here! It allows to customize it using bookmarklet!
From security point of view, I am not sure this is good or not! @pmario may give us his opinion here!
But for personal use this is amazing! Like you I have a bookmarklet, it injects some of most common Plugins when I visit a web TiddlyWiki or when I have downloaded one and open locally!

Yes, I think we should evaluate this further but as long as one trusts the source of such bookmarklets, and they don’t miss represent themselves, that is, look like they are doing something they are not (spoofing) I think they are somewhat safe.

  • They are readable and plain text “interpreted” not compiled code, thus visible.
  • Bookmarklets in your bookmarks can only be triggered by the user interactively
    • Although we can move them into tiddlywiki
  • They apply to the current tab or window
  • They can’t get around the saving security already present in the tab/wiki
  • They typically result in interactions with the user, and are thus visible

For personal use they are: “Must Have” ;-).

1 Like

Code in bookmarklets is executed in context of the page. So it’s the same thing as using plugins. You need to trust the author. I personally will always want to read the content of the bookmarklet.

So I think the code from Bookmarklets, Just in Time install, Windows work flow and Timimi - #8 by TW_Tones should have been presented similar to the code below.

It’s human readable, which imo is important. Even if users do not fully understand, what’s going on, they can read it. If they are interested, they can look up the functions and see what they do and if they are secure for them. …

If they are not interested to look up the functions, they need to trust the author. … But at least the user has the choice.

<a href="javascript:
(function() {
	function getFilenameFromUrl(url) {
		var path = new URL(url).pathname;
		return path.substring(path.lastIndexOf('/') + 1);
	}

	function getLastFolderFromUrl(url) {
		var path = new URL(url).pathname;
		var pathArray = path.split('/').filter(item => item.length > 0);
		return pathArray.length > 1 ? pathArray[pathArray.length - 2] : '';
	}
	if (window.name) {
		if (confirm('Window name already set: ' + window.name + '. Do you want to clear the window name?')) {
			window.name = '';
			alert('Window name cleared.');
		} else {
			alert('Window name not cleared.');
		}
	} else {
		var url = document.location.href;
		var isFileUrl = url.startsWith('file://');
		var identifier;
		if (isFileUrl) {
			var filename = getFilenameFromUrl(url);
			identifier = (filename === 'index.html') ? getLastFolderFromUrl(url) : filename;
		} else {
			identifier = document.location.hostname;
		}
		window.name = identifier;
		alert('Window name set to: ' + identifier);
	}
})();
">Set or Clear Window Name</a>
3 Likes

Hi @TW_Tones , I’ve been meaning to try your Bookmarklet solution for a while and now getting around to it. I’ve just been reading through your demo site and struggling to understand how I can create my own. The only way I can see shown is that within your site there are some toolbar buttons that I can drag places, but I would think your intent is that we (the user) can make changes in our own wiki and then save those changes into Bookmarklets of our own and apply at will. I’m sure it must be obvious but I’m not seeing how I do that. I would think you’d have the “builder mechanism” in a state where we can import / install in our own wikis or something.

@stobot I am preparing for a bush walk and will be out for some hours but so you can proceed.

https://bookmarklets.tiddlyhost.com/

  • drop what you want to package on the bookmarklets wiki
  • use advanced search filters to list your tiddlers
  • use the buttons in advanced search buttons to;
    • export
    • drag a bookmarklet to your favorites
    • generate a tiddler containing a bookmarklet

These tools may be easy to package and share. See the packages tab but they may need effort to fully document for public consumption.