You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

projectdoc Toolbox

Hides a static set of elements on a Confluence page.

Identifier
de.smartics.userscripts.confluence.hide-page-elements-anonymous
Type
Repository
Since
1.0

This simple script is configured to hide elements on a Confluence page. The elements to hide includes likes, labels, comments, entries from the page menu, help menu, space tools, and navigation sidebar.

Code

The code of the script for reference.

hide-page-elements-anonymous.js
/*
 * Copyright 2019-2024 Kronseder & Reiner GmbH, smartics
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
"use strict";

AJS.toInit(function () {
  const logToConsole = false;

  if (logToConsole) {
    AJS.log("[hide-page-elements-anonymous] Checking ...");
  }

  if (AJS.Meta.get('remote-user') == '') {
    if (logToConsole) {
      AJS.log("[hide-page-elements-anonymous] Hiding likes, labels, and comments ...");
    }
    AJS.$('#likes-section').hide();
    AJS.$('#labels-section').hide();
    AJS.$('#comments-section').hide();

    if (logToConsole) {
      AJS.log("[hide-page-elements-anonymous] Hiding people and tag cloud ...");
    }
    // AJS.$('#space-directory-link').hide()
    AJS.$('#people-directory-link').hide();
    AJS.$('#tagcloud-link').hide();
    // AJS.$('#create-page-button').hide();

    if (logToConsole) {
      AJS.log("[hide-page-elements-anonymous] Hiding tags, wiki, calendar, and quick links ...");
    }
    //  AJS.$('.acs-nav-item.profile').hide();
    AJS.$('.acs-nav-item.tags').hide();
    AJS.$('.acs-nav-item.wiki').hide();
    AJS.$('.acs-nav-item.space-calendar-sidebar-link').hide();
    AJS.$('.acs-nav-item.blog').hide();
    AJS.$('.quick-links-wrapper').hide();
    //  AJS.$('.parent-item').hide();

    if (logToConsole) {
      AJS.log("[hide-page-elements-anonymous] Hiding space tools ...");
    }
    AJS.$('.space-tools-section').hide();

    if (logToConsole) {
      AJS.log("[hide-page-elements-anonymous] Hiding page menu items ...");
    }
    // AJS.$('#action-menu-link').hide();
    AJS.$('#view-attachments-link').hide();
    AJS.$('#action-view-history-link').hide();
    AJS.$('#view-page-info-link').hide();
    AJS.$('#view-resolved-comments').hide();
    AJS.$('#view-in-hierarchy-link').hide();
    AJS.$('#action-view-source-link').hide();
    //AJS.$('#action-export-pdf-link').hide();
    //AJS.$('#action-export-word-link').hide();
    AJS.$('#action-copy-page-link').hide();

    if (logToConsole) {
      AJS.log("[hide-page-elements-anonymous] Hiding help menu items ...");
    }
    // AJS.$('#help-menu-link').hide();
    // AJS.$('#confluence-help-link').hide();
    // AJS.$('#keyboard-shortcuts-link').hide();
    // AJS.$('#feed-builder-link').hide();
    AJS.$('#whats-new-menu-link').hide();
    AJS.$('#gadget-directory-link').hide();
    // AJS.$('#confluence-about-link').hide();
  }
});

Details

There is no configuration option for the script.  In case the elements hidden by this script do not fit your use case, please adjust the script accordingly.

App for Confluence to Hide Elements on Confluence

 

If you are looking for a tool that allows to configure the elements on a page to hide easily, please have a look at HideElements for Confluence by Lively Apps.

Resources

More information on this topic is available by the following resources.

How to hide elements in Confluence using CSS or JavaScript
Article on Confluence Support showing how to hide specific elements displayed in Confluence page using CSS or JavaScript.
  • No labels