'How to reoder video tiles in Jitsi?

Last year, I wrote a bookmarklet that allowed to reorder Jitsi video tiles in alphabetic order.

Unfortunately, the script does not seem to work with the recent Jitsi versions anymore. I have already adjusted the access to the required elements, this is working fine again. However, the order: n attribute of the elements is ignored know, even when I set the parent to display:flex, remove the position: absolute and the left|top:n px. I played around with the CSS and looked into documentation, but given I am no frontender, I am currently stuck.

How can I change the CSS, so that the tiles are reordered?

As a clarification, I am only looking for where I need which changes in the CSS, no scripted solution. I can take care of the scripting. Achieving a swap of two video tiles while not breaking the look would be sufficient probably.

The below information are not necessary, but might be helpful to answer the question. Below is a screenshot showing the position in the DOM tree:

DOM tree leading to the video tiles (seems I need more reputation to embed the image)

And here is the the javascript that allows to directly access the elements:

var numberOfVideos;

  function getNumberOfParticipants(){
    // works
  }

  function getNameOfParticipant(i){
     var container = $('#remoteVideos')[0];
     var jChildren = $(container).children();
     var jChildren2 = jChildren[1].firstChild.children;
     return [jChildren2[i].getElementsByClassName("displayname")[0].innerHTML, jChildren2[i] ];
  }

  function sortParticipants(){
    numberOfVideos = getNumberOfParticipants();

    var names = new Array();

    //only applicable in tiles mode!
    for(i=0; i<numberOfVideos; i++) {
      names[i] = new Array (2);
      names[i] = getNameOfParticipant(i);
    }

    //sort Array
    names.sort((a, b) => a[0].localeCompare(b[0]));

    //reorder the tiles
    for(i = 0; i < numberOfVideos; i++){
      $(names[i][1]).css('order', i); //this is the line that worked in 2021, but the `order` attribute is now being ignored
    }
  }

https://github.com/kaiyazeera/jitsi-bookmarklets/blob/master/alphabeticSort-auto0.js



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source