Alter module js for on custom page
In the switch statement you provide, you are switching over $environment variable. It sounds like it will never be passed a URL or 'custom page' value.

You are also trying to use $node object but you have not loaded it from your code. You are also not passing $node as an argument. Also an $adobe_dtm variable is used but never defined. Plus, you are using = to do an equality check, you need == or ===. = is assigning 'my_node_id' to your variable instead of compare it.

In order to have a $node object present in this function, you need to do one of two things to get it:


$node = menu_get_object('node');
$node = node_load(arg(1));


Then you can just add this after the switch statement:

function module_script_src($environment) {
  $script = '';
  $script_id = variable_get('script_id', '');
  $script_hash = variable_get('script_hash', '');

  switch ($environment) {
    case 'prod':
      if ($script_id &amp;&amp; $script_hash) {
        $script = '//example.com/' . $script_id . '/lib-' . $script_hash . '.js';
      }
      break;

    case 'dev':
      if ($adobe_dtm &amp;&amp; $site_hash) {
        $script = '//example.com/' . $script_id . '/lib-dev' . $script_hash . '.js';
      }
      break;

  }

  if ($node = menu_get_object('node')) {
    if ($node-&gt;nid == "my_node_id"):
      $script = '//example.com/' . $script_id . '/custom-' . $script_hash . '-.js';
    }
  }

  return $script;
}


You may need to think through the cases involved in building the script value. It looks like the switch statement is not even necessary, because $script value is basically the same - in which case you can clean up the code by simplifying it.