Hide header elements script no longer works
Asked by Todd Winton:

Using the below script, I previously hid the entire header bar for a specific user. However this is no longer working. I do not know when it stopped working. Is there something that has changed or that I need to change to the script?

\<script\>  
AJS.toInit(function(){  
if (AJS.params.remoteUser == 'ctsidocs'){  
AJS.$("#space-tools-menu-trigger").hide();

AJS.$('#action-menu-link').hide();  
AJS.$('#children-section').hide();  
AJS.$('#shareContentLink').hide();  
AJS.$('#likes-section').hide();  
AJS.$('#labels-section').hide();  
AJS.$('#watch-content-button').hide();  
}  
});  
\</script\>


Answers:
author: Vitor LC
body: Hi [@Todd Winton](/t5/user/viewprofilepage/user-id/698273)

Which version of Confluence are you using? Did you make any recent changes?

Cheers

comments: author: Todd Winton
body: 7.2.2

The only change I have made is to disable TLS 1.1 and 1.0. Can't really say if that was working before then or not.


author: Vitor LC
body: I wasn't sure if the IDs and class names were still the same in version 7 but I've tested the script now in Confluence 7.3 and it works.

The code is correct and I take you have it implemented in the Custom HTML. Have you tried debugging it with your browser Dev tools? Have you tested it in more than one browser?


author: repi
body: I tested the macro in the 7.5.0 version in the html macro and it works.

Good for a user macro with a selection function for the user and the different sections. :)


author: Todd Winton
body: Yes, I have implemented in the custom HTML. In IE I am seeing an error:

Failed to run init function: Unable to get property 'isVisible' of undefined or null reference function(){AJS.Editor.isVisible()?k():$("#editPageLink").on("click.enterEditMode",k)} TypeError: Unable to get property 'isVisible' of undefined or null reference TypeError: Unable to get property 'isVisible' of undefined or null reference  
at Anonymous function (<https://insight.ctsi-global.com/s/d41d8cd98f00b204e9800998ecf8427e-CDN/gyatix/8401/b3e5d654c041312f7bfcd7d5f17e71f59e8621d2/6.4.4/_/download/batch/com.adaptavist.confluence.contentFormattingMacros:macro-analytics-bundle/com.adaptavist.confluence.contentFormattingMacros:macro-analytics-bundle.js:5:5183>)  
at Anonymous function (<https://insight.ctsi-global.com/s/dd456c90c1cf6183e441fcb16222aab7-CDN/gyatix/8401/b3e5d654c041312f7bfcd7d5f17e71f59e8621d2/76a37112388fab3cd816f6b922119db0/_/download/contextbatch/js/_super/batch.js?locale=en-US:2110:486>)  
"Failed to run init function: Unable to get property 'isVisible' of undefined or null reference"  
function(){AJS.Editor.isVisible()?k():$("#editPageLink").on("click.enterEditMode",k)}  
{  
\[functions\]: ,  
__proto__: { },  
description: "Unable to get property 'isVisible' of undefined or null reference",  
message: "Unable to get property 'isVisible' of undefined or null reference",  
name: "TypeError",  
number: -2146823281,  
stack: "TypeError: Unable to get property 'isVisible' of undefined or null reference  
at Anonymous function (<https://insight.ctsi-global.com/s/d41d8cd98f00b204e9800998ecf8427e-CDN/gyatix/8401/b3e5d654c041312f7bfcd7d5f17e71f59e8621d2/6.4.4/_/download/batch/com.adaptavist.confluence.contentFormattingMacros:macro-analytics-bundle/com.adaptavist.confluence.contentFormattingMacros:macro-analytics-bundle.js:5:5183>)  
at Anonymous function (<https://insight.ctsi-global.com/s/dd456c90c1cf6183e441fcb16222aab7-CDN/gyatix/8401/b3e5d654c041312f7bfcd7d5f17e71f59e8621d2/76a37112388fab3cd816f6b922119db0/_/download/contextbatch/js/_super/batch.js?locale=en-US:2110:486>)",  
Symbol()_7.kpypysfdtek: undefined,  
Symbol()_j.kpypysfdtbb: undefined,  
Symbol()_k.kpypysfdtbb: undefined,  
Symbol()_l.kpypysfdtbb: undefined,  
Symbol()_m.kpypysfdtbb: undefined,  
Symbol()_n.kpypysfdtbb: undefined,  
Symbol(_latestValue)_o.kpypysfdtbb: undefined,  
Symbol(_state)_p.kpypysfdtbb: undefined  
}  
"TypeError: Unable to get property 'isVisible' of undefined or null reference  
at Anonymous function (<https://insight.ctsi-global.com/s/d41d8cd98f00b204e9800998ecf8427e-CDN/gyatix/8401/b3e5d654c041312f7bfcd7d5f17e71f59e8621d2/6.4.4/_/download/batch/com.adaptavist.confluence.contentFormattingMacros:macro-analytics-bundle/com.adaptavist.confluence.contentFormattingMacros:macro-analytics-bundle.js:5:5183>)  
at Anonymous function (<https://insight.ctsi-global.com/s/dd456c90c1cf6183e441fcb16222aab7-CDN/gyatix/8401/b3e5d654c041312f7bfcd7d5f17e71f59e8621d2/76a37112388fab3cd816f6b922119db0/_/download/contextbatch/js/_super/batch.js?locale=en-US:2110:486>)"


author: Vitor LC
body: Hi.

It is indeed a bit puzzling.

Could you use the console in Dev Tools to confirm that the user accessing the Wiki is *++ctsidocs++* and not one other, by typing "++*AJS.params.remoteUser*++ ", or in alternative view the page source and search for the meta tag "*++ajs-remote-user++*".


author: repi
body: Found a good macro by Georg Lewe on the topic of "hide sections", which I have expanded a little.

<https://support.lewe.com/docs/confluence/confluence-user-macros/hide-sections/>

Here is the macro with the extended code:

```
##* HIDE SECTIONS
##*
##* This Confluence user macro hides Confluence sections and elements of your page.
##*
##* Version: 2.0.000
##* Date: 2020-07-09
##* Author: George Lewe, Reinhard Piltz
##* Source: https://github.com/glewe/hide-sections
##* License: GNU LGPLv3
##*
##* Macro body: None
##* Body processing: None
##*

#* ----------------------------------------------------------------------------
* PARAMETER
*#
## @param HideSpaceTools:title=Hide Space Tools|type=boolean|desc=Select to hide space tools|default=false
## @param HideWatchContent:title=Hide Watch Content Button|type=boolean|desc=Select to hide watch content button|default=false
## @param HideShareContent:title=Hide Share Content Link|type=boolean|desc=Select to hide share content link|default=false
## @param HideUserMenu:title=Hide User Menu Link|type=boolean|desc=Select to hide user menu link|default=false
## @param HideMetadata:title=Hide Page Metadata|type=boolean|desc=Select to hide the page metadata section.|default=false
## @param HideBreadcrumbs:title=Hide Breadcrumbs|type=boolean|desc=Select to hide the breadcrumbs section.|default=false
## @param HideChildren:title=Hide Children|type=boolean|desc=Select to hide the children section.|default=false
## @param HideComments:title=Hide Comments|type=boolean|desc=Select to hide the comments section.|default=false
## @param HideLabels:title=Hide Labels|type=boolean|desc=Select to hide the labels section.|default=false
## @param HideLikes:title=Hide Likes|type=boolean|desc=Select to hide the likes section.|default=false
## @param HideModification:title=Hide Modification Info|type=boolean|desc=Select to hide the modification info section.|default=false
## @param HideTitle:title=Hide Page Title|type=boolean|desc=Select to hide the page title.|default=false
## @param HideSidebar:title=Hide Sidebar|type=boolean|desc=Select to hide the sidebar.|default=false
## @param HideToolsMenu:title=Hide Tools Menu|type=boolean|desc=Select to hide the tools menu.|default=false

#* ----------------------------------------------------------------------------
* PROCESS INPUT
*#
#set ($hideScripts="") 
#set ($hideStyles="")
#set ($hideAJScripts="")

#if ($paramHideSpaceTools==true)
#set($hideAJScripts=$hideAJScripts+"AJS.$('#space-tools-menu-trigger').hide();")
#end 
#if ($paramHideWatchContent==true)
#set($hideAJScripts=$hideAJScripts+"AJS.$('#watch-content-button').hide();")
#end 
#if ($paramHideShareContent==true)
#set($hideAJScripts=$hideAJScripts+"AJS.$('#shareContentLink').hide();")
#end 
#if ($paramHideUserMenu==true)
#set($hideAJScripts=$hideAJScripts+"AJS.$('#user-menu-link').hide();")
#end 
#if ($paramHideMetadata==true)
#set($hideStyles=$hideStyles+"div#page-metadata-banner{display:none;}")
#end
#if ($paramHideBreadcrumbs==true)
#set($hideStyles=$hideStyles+"div#breadcrumb-section{display:none;}")
#end
#if ($paramHideChildren==true)
#set($hideStyles=$hideStyles+"div#children-section.pageSection{display:none;}")
#end
#if ($paramHideComments==true)
#set($hideStyles=$hideStyles+"div#comments-section{display:none;}")
#end
#if ($paramHideLabels==true)
#set($hideStyles=$hideStyles+".label-list{display:none;}")
#end
#if ($paramHideLikes==true)
#set($hideStyles=$hideStyles+"div#likes-section{display:none;}")
#end
#if ($paramHideModification==true)
#set($hideStyles=$hideStyles+"li.page-metadata-modification-info{display:none;}a#content-metadata-page-restrictions{display:none;}a#content-metadata-attachments{display:none;}")
#end
#if ($paramHideTitle==true)
#set($hideScripts=$hideScripts+"document.getElementById('title-text').innerHTML='&nbsp;';")
#end
#if ($paramHideSidebar==true)
#set($hideStyles=$hideStyles+".ia-fixed-sidebar {display: none;}.ia-splitter #main,.ia-splitter #footer{margin-left:0px !important;}")
#end
#if ($paramHideToolsMenu==true)
#set($hideStyles=$hideStyles+"a#action-menu-link {display: none;}")
#end

#* ----------------------------------------------------------------------------
* OUTPUT
*#
#if ($hideStyles!="")
<style type="text/css">$hideStyles</style>
#end 
#if ($hideScripts!="")
<script>$hideScripts</script>
#end
#if ($hideAJScripts!="")
<script type="text/javascript">AJS.toInit(function(){$hideAJScripts});</script>
#end
```


author: Todd Winton
body: [@Vitor LC](/t5/user/viewprofilepage/user-id/734159)

The error I pasted was genered while logging in as the specified user.


author: Vitor LC
body: Hi Todd,

did you find a solution for this problem?

Cheers,

Vitor


author: Rich Bayless
body: The link repi provided (<https://support.lewe.com/docs/confluence/confluence-user-macros/hide-sections/>) is no longer valid - as they've completely changed their website (and now leverage github for managing/providing such macros).

Link to Lewe Support's "Documentation" page: <https://lewe.gitbook.io/lewe-support/>

Link to its "Confluence User Macros" page: <https://lewe.gitbook.io/confluence-user-macros/>

Link to their "hide sections" page: <https://github.com/glewe/confluence-user-macros/tree/master/src/hide-sections>

**NOTE:** It seems they no longer provided actual CSS; rather, they now provide a "hide-sections.vtl" file which they claim will do the same thing (albeit via a different means - i.e., using a Confluence "user macro" instead of a Confluence "include page" macro referencing a page with an embedded CSS Stylesheet macro.