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

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