Elgg Lightbox via URL

Hello,

I want a lightbox to appear when i hit a specific url, not by clicking a link. The link is external.

Example: when someones hits www.example.com/activity/all?ref=twitter in a browser, then it must trigger a lightbox. I have done the following with the help of this community but still i need some help.

// views/default/js/my/twitter/lightbox.js
define(function(require) {
  var elgg = require('elgg');
  
  // Pop the lightbox
  elgg.lightbox({...}); //this doesn't work
});

// start.php
if (preg_match("/[&\?]ref=twitter(&.*)?/", current_page_url()) {
  elgg_require_js('my/twitter/lightbox');
}

Also, above case is for a specific plugin only but i also want to handle whenever a link with ref=twitter is hit, a lightbox must be opened. I don't want to rewrite all the syntax in every plugins.

Thanks in advance.