Script - Surface rebuild

 From:  Samuel Zeller
5806.7 
That's not really what I need,

I want to remove the useless lines (so take every planar surface, look for the edges and only keep the outside ones)

So for exemple in that picture there's two triangular surfaces, I want to do some sort of "Union" so it's not two triangles anymore but just a planar rectangle.