/*eslint-env es6*/ /** * Hide a primary navigation item by href * @param {string|Array} hrefs The link that should be hidden */ export function hide_primary(hrefs) { let element = document.createElement('style'); document.head.appendChild(element); let sheet = element.sheet; if(typeof hrefs === 'string' || hrefs instanceof String){ hrefs = [hrefs]; } if(typeof hrefs === 'object' && Array.isArray(hrefs)){ for(const ix in hrefs){ const href = hrefs[ix]; let style = ` .primary-navigation li.nav-item > a[href*="${href}"] { display: none; } `; sheet.insertRule(style, sheet.cssRules.length); style = ` #usernavigation a[href*="${href}"] { display: none; } `; sheet.insertRule(style, sheet.cssRules.length); } } }