Permission Settings via Chrome Extensions

Here is a Chrome Extension that allows you to set all the specific permissions you want with one click. This version is for Site Settings, so you have to be logged in and on the Site Permissions tab before clicking.
You should be able to run it in Developer Mode on your computer without going through all Google’s requirements. You are free to make your own version and publish it so that your users can access it via the Google Store.
Edit the ‘service-worker.js’ by copying the main const, and deleting the ones you don’t want set, easy as pie.
There is no automated way (via REST API, etc) to set permissions on a site, hence this.

Example settings:
//full list for ease
const all = [“view”, “add-children”, “edit”,“edit-permissions”,
“folders-view”, “folders-add-children”, “folders-edit”,“folders-edit-permissions”,
“containers-view”,“containers-edit”,“containers-publish”,“containers-edit-permissions”,
“templates-view”,“templates-edit”,“templates-publish”,“templates-edit-permissions”,
“template-layouts-view”,“template-layouts-edit”,“template-layouts-publish”,“template-layouts-edit-permissions”,
“pages-view”,“pages-edit”,“pages-publish”,“pages-edit-permissions”,
“links-view”,“links-edit”,“links-publish”,“links-edit-permissions”,
“structures-view”,“structures-edit”,“structures-publish”,“structures-edit-permissions”,
“content-view”,“content-edit”,“content-publish”,“content-edit-permissions”,
“rules-view”,“rules-publish”];

//choose which ones you actually want to set from the full list
const perms = [“view”, “add-children”, “edit”,
“folders-view”, “folders-add-children”, “folders-edit”,
“containers-view”,
“templates-view”,
“pages-view”,“pages-edit”,“pages-publish”,
“links-view”,“links-edit”,“links-publish”,
“structures-view”,“structures-edit”,“structures-publish”,
“content-view”,“content-edit”,“content-publish”];

Okay, dotCMS will not allow me to upload a .js or a .zip file. If you want the manifest source, just ask. Here’s the code if you want to see how it is done:

function setPermissions() {
//actual html we need is in an iframe on the page.
iframe=document.getElementById(‘detailFrame’).contentWindow.document;

whereall=iframe.getElementsByClassName(‘dijitAccordionInnerContainerSelected’);
where=whereall[0];
where.style.backgroundColor=“#ada”;
//finds the selected site dropdown and colors it green so we know we are in the right place.

//split out the site-id from the element
//example : permissionsAccordionPane-811cd149d1bf82ee58d8c1917e7c3cd6_wrapper
iden=where.id;
ide=iden.split(‘-’)[1];
id=ide.split(‘_’)[0];
//id is now ‘811cd149d1bf82ee58d8c1917e7c3cd6’

//full list for ease
const all = [“view”, “add-children”, “edit”,“edit-permissions”,
“folders-view”, “folders-add-children”, “folders-edit”,“folders-edit-permissions”,
“containers-view”,“containers-edit”,“containers-publish”,“containers-edit-permissions”,
“templates-view”,“templates-edit”,“templates-publish”,“templates-edit-permissions”,
“template-layouts-view”,“template-layouts-edit”,“template-layouts-publish”,“template-layouts-edit-permissions”,
“pages-view”,“pages-edit”,“pages-publish”,“pages-edit-permissions”,
“links-view”,“links-edit”,“links-publish”,“links-edit-permissions”,
“structures-view”,“structures-edit”,“structures-publish”,“structures-edit-permissions”,
“content-view”,“content-edit”,“content-publish”,“content-edit-permissions”,
“rules-view”,“rules-publish”];

//choose which ones you actually want to set from the full list
const perms = [“view”, “add-children”, “edit”,
“folders-view”, “folders-add-children”, “folders-edit”,
“containers-view”,
“templates-view”,
“pages-view”,“pages-edit”,“pages-publish”,
“links-view”,“links-edit”,“links-publish”,
“structures-view”,“structures-edit”,“structures-publish”,
“content-view”,“content-edit”,“content-publish”];

for (i=0;i<perms.length;i++){
id1=perms[i]+‘-permission-’+id;
//example add-children-permission-811cd149d1bf82ee58d8c1917e7c3cd6
console.log(id1);
box=iframe.getElementById(id1);
box.style.opacity=1;//style them so we can see it set them properly.
box.checked=true;//this is actually only visual
box.click();//this actually triggers the onclick event on the item so that dijit knows it is triggered.
}
}

chrome.action.onClicked.addListener((tab) => {
if (!tab.url.includes(‘chrome://’)) {
chrome.scripting.executeScript({
target: { tabId: tab.id },
function: setPermissions
});
}
});

1 Like

This is a really interesting approach Mark! Never thought about firing javascript to do all the permission checks. Did you ever get this into the Chrome store or are you just firing it in browser?

It’s in the Chrome store, search on ‘dotCMS permtool’.
It’s really just that one .js file and an icon, screenshot and manifest file. It’s the simplest extension possible.

M