Chrome Extension - SharePoint - Tag Unique Permission Lists

Google Chrome extension (or Plugin or AddIn) is a useful medium to share features or tools across the tech community. I have prepared one small Chrome extension for SharePoint (2013, 2016 and Online) which tags (marks with red button) unique permission lists on SP Site’s Site Content Page. This is done using SP REST API calls. I will walk you through the major steps I followed for creating this Chrome extension (SharePoint - Tag Unique Permission Lists) and how to publish it. You may create your own extension by following these simple steps.

Step 1 - Create new Chrome Extension

There is a defined file structure to be followed while building chrome extension. The most important and must-have file is “manifest.json”.

  1. Create any folder (ex: “My First Chrome Extension”) in your local drive.

  2. Create new file named “manifest.json” in it.

  3. Open “manifest.json” empty file in notepad and paste following code in it. You may update the code based on your need. This code loads js scripts on page load, but you can design your code in such a way that certain actions can be performed on browser actions. More details,
  1. {  
  2.     "manifest_version": 2,  
  3.     "name""SharePoint - Tag Unique Permission Lists",  
  4.     "short_name""Tag SP Lists",  
  5.     "description""It tags unique permissions lists with red buttons on Site Contents page. Compatible - SP 2013, 2016 and Online.",  
  6.     "version""2.0",  
  7.     "icons": {  
  8.         "16""images/icon16.png",  
  9.         "48""images/icon48.png",  
  10.         "128""images/icon128.png"  
  11.     },  
  12.     "content_scripts": [{  
  13.         "all_frames"true,  
  14.         "css": ["scripts/css/style.css"],  
  15.         "js": ["scripts/js/jquery-1.9.1.min.js""main.js"],  
  16.         "matches": ["*://*/*viewlsts.aspx*"],  
  17.         "run_at""document_end"  
  18.     }]  
  19. }  

Description of above used manifest.json properties:

    • manifest_version => Integer must be always 2 (applicable since Chrome 18). Mandatory.
    • name => Name of the extension. Type is String. Plain Text. Maximum 45 characters. Mandatory.
    • short_name => Short name of the extension. Type is String. Plain Text. Maximum 12 characters. Optional.
    • description => Description of the extension. Type is String. Plain Text. Maximum 132 characters. Optional.
    • version => One to four dot-separated integers identifying the version of this extension. Must be between 0 and 65535.
    • icons => Icons to be used in the extension. Ideally to be in PNG format. Optional.
    • content_scripts => Content scripts are JavaScript files that run in the context of web pages. By using the standard Document Object Model (DOM), they can read details of the web pages the browser visits, or make changes to them. Optional.

      • all_frames (Boolean, Optional)
        Controls whether the content script runs in all frames of the matching page, or only the top frame.

      • css (array of strings, Optional)
        The list of CSS files to be injected into matching pages. These are injected in the order they appear in this array, before any DOM is constructed or displayed for the page. We are using css here (from folder “scripts/css/”) to render style for red button which will be shown on those list tiles which are having unique permissions on SP Site Content Page.

      • js (array of strings, Optional)
        The list of JavaScript files to be injected into matching pages. These are injected in the order they appear in this array. jquery-1.9.1.min.js file is added at the first place and is referred in js file. Both files are placed in folder “scripts/js/”. main.js file is having actual js code logic(using REST API) which fetches only unique permission and non-hidden lists and tags them with red button.

      • matches (array of strings, Required)
        Specifies which pages this content script will be injected into. Match Patterns. We are matching “aspx” (SP Site Content Page) page here only so that script won’t run on other pages.

      • run_at (string, Optional)
        Controls when the files in js are injected. It can be "document_start", "document_end", or "document_idle". Default is "document_idle". We are running our script files at the end of document object model life cycle. 
  1. This is how root folder structure looks.


Step 2 - Test the package locally 

  1. Open the Google Chrome browser

  2. Click on 3 dots in the corner (settings) which show tooltip as “customize and control Google Chrome.”

  3. Navigate to More Tools >> Extensions

  4. Click on “Load unpacked extension…” button

  1. Open “My First Chrome Extension” folder

  2. If there are no errors, then this extension will load without any problem. If there are errors visible, fix those issues in files and just reload extension again.

  3. If you want to run extension in Incognito mode then check this setting.


Step 3 - Prepare the package to be published in Google Web Store

  1. Now once we are finished with testing the extension, just create a .zip file of the parent folder. (for ex: “My First Chrome”)

  2. Open Google web store for extensions

  3. Login with your gmail account

  4. Click on settings icon at the top right and select Developer Dashboard

  5. Click on Add new item and upload your zip file here


  6. Follow the steps to fill in details like icons, screenshots, descriptions etc. Appropriate descriptions, icons and screenshots will correctly emphasize your extension’s purpose.

  7. The most important thing to mention here is that Google Chrome Extension is not free. You will have to pay a nominal $5 fee before publishing the Chrome extension to the store. This fee will be valid for a total of 20 extensions. So ideally for the next 19 extensions you don’t have to pay anything.

  8. Once you pay $5 and everything looks fine then just publish your extension.

  9. In one hour or so, you can see your extension in the Google web store.

  10. That’s it!