• Activity
  • Votes
  • Comments
  • New
  • All activity
  • Showing only topics with the tag "mentions". Back to normal view
    1. Tildes User Script: Drag and drop usernames in order to mention them in your comments

      It is was a tedious task to mention users: copy, type, paste. This script makes it a single step: drag and drop any username on to the comment you're composing, and tada! It's there. Here is the...

      It is was a tedious task to mention users: copy, type, paste. This script makes it a single step: drag and drop any username on to the comment you're composing, and tada! It's there.

      Here is the script:

      // ==UserScript==
      // @name     tildesDragNDropUsernameForMention
      // @version  1
      // @grant    none
      // @namespace   tildes.net
      // ==/UserScript==
      
      var userLinks = document.querySelectorAll('a.link-user');
      
      var dragstartHandler = function (event) {
        var text = event.target.innerText;
        if(!text.startsWith('@')){
          text = "@" + text;
        }
        event.dataTransfer.setData("text", text);
        event.dataTransfer.dropEffect = 'copy';
      }
      
      userLinks.forEach(function (each) {
        each.setAttribute('draggable', true);
        each.ondragstart = dragstartHandler;
      });
      

      Patches welcome!

      Edit: remove useless code

      9 votes