Show overlapping groups in Confluence's space permisisons

what the name says

  1. // ==UserScript==
  2. // @name Show overlapping groups in Confluence's space permisisons
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description what the name says
  6. // @author Dennis Stengele
  7. // @match https://*.atlassian.net/wiki/spaces/spacepermissions.action*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=atlassian.net
  9. // @grant none
  10. // @run-at document-end
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. /* jshint esversion: 8 */
  15.  
  16. (async function () {
  17. 'use strict';
  18.  
  19. const baseUrl = location.origin;
  20.  
  21. const permissionGroups = Array.from(document.querySelectorAll("table#gPermissionsTable tr.space-permission-row > th")).map((node) => node.innerText);
  22.  
  23. const userRows = Array.from(document.querySelectorAll("table#uPermissionsTable tr.space-permission-row"));
  24.  
  25. for (const userRow of userRows) {
  26. const userKey = userRow.dataset.key;
  27.  
  28. const userGroups = await fetch(`${baseUrl}/wiki/rest/api/user/memberof?${new URLSearchParams({ accountId: userKey })}`).then(
  29. response => { return response.json(); }
  30. ).then(
  31. json => { return json.results.map((groupObject) => { return groupObject.name; }); }
  32. );
  33.  
  34. const intersect = permissionGroups.filter((x) => { return userGroups.includes(x); });
  35.  
  36. if (0 == intersect.length) { continue; }
  37.  
  38. const usernameCell = userRow.querySelector("th");
  39.  
  40. const userNameValue = usernameCell.innerText;
  41.  
  42. console.log(`User ${userNameValue} (Key: ${userKey}) has groups [${userGroups.join(", ")}], intersected to [${intersect.join(", ")}]`);
  43.  
  44. const newUsernameValue = `${userNameValue} (${intersect.join(", ")})`;
  45.  
  46. usernameCell.innerText = newUsernameValue;
  47. }
  48. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址