export class DOM { static isElement ( element ) { return element instanceof Element || element instanceof HTMLDocument ; } static removeAllTargetBlankFromLinks ( ) { const { links } = document ; let i ; let length ; for ( i = 0 , length = links . length ; i < length ; i ++ ) { links [ i ] . target == "_blank" && links [ i ] . removeAttribute ( "target" ) ; } } static disableAllUserEvents ( eventExceptions ) { console . debug ( "Disabling all user events" ) ; const events = [ "contextmenu" , "dblclick" , "mousedown" , "mouseenter" , "mouseleave" , "mousemove" , "mouseover" , "mouseout" , "mouseup" , "keydown" , "keypress" , "keyup" , "blur" , "change" , "focus" , "focusin" , "focusout" , "input" , "invalid" , "reset" , "search" , "select" , "submit" , "drag" , "dragend" , "dragenter" , "dragleave" , "dragover" , "dragstart" , "drop" , "copy" , "cut" , "paste" , "mousewheel" , "wheel" , "touchcancel" , "touchend" , "touchmove" , "touchstart" , ] ; const eventExceptionNames = Object . keys ( eventExceptions ) ; const handler = ( event ) => { event . stopPropagation ( ) ; event . preventDefault ( ) ; if ( eventExceptionNames . includes ( event . type ) ) { eventExceptions [ event . type ] ( event ) ; } return false ; } ; for ( let i = 0 , l = events . length ; i < l ; i ++ ) { window . addEventListener ( events [ i ] , handler , true ) ; } return ( ) => { for ( let i = 0 , l = events . length ; i < l ; i ++ ) { window . removeEventListener ( events [ i ] , handler , true ) ; } } ; } } export interface iPageSeoMeta { [ metaName ] : { name : string ; value : string ; } ; } export function getAllSeoMetaInfo ( ) { const metaElements = [ ... ( document . querySelectorAll ( "meta" ) as any ) ] ; const metaTagsValuesMap = metaElements . reduce ( ( prev , current ) => { const name = current && typeof current . getAttribute === "function" ? current . getAttribute ( "name" ) : null ; if ( ! name ) { return prev ; } return { ... prev , [ name ] : { name , value : current . content } } ; } , { } ) ; return metaTagsValuesMap ; } export function openLinkInNewTab ( url ) { const link = document . createElement ( "a" ) ; link . href = url ; link . target = "_blank" ; const event = new window . MouseEvent ( "click" , { view : window , bubbles : true , cancelable : true , } ) ; link . dispatchEvent ( event ) ; }