Hide tabs on mobile device

Hello,

I would like to build 2 different tabs for each device: 1 tab for mobile device and another for common desctop pc.

I have this function added to my head section:

<script>
function myFunction(x) {
 if (x.matches) { // If media query matches
   window.location.replace("http://ip-address/ui/#!/4");
}else{
   window.location.replace("http://ip-address/ui/#!/0")
}
}

var x = window.matchMedia("(max-width: 700px)")
myFunction(x) // Call listener function at run time
x.addListener(myFunction) // Attach listener function on state changes
</script>

and it works very well and I get relocated properly, but now I want to hide from menu the tab 0 when using mobile device and also hide tab 4 when using desctop.

Does it work with ui_control??

Someone any idea?

Update:

Ok I found the way to hide tabs with ui_control. But I still need some msg to return from function above.
How to add a return payload to this function?