Getting current page macro information through JavaScript?

Kevin Brunette December 1, 2017

Hello!

I have some users who are bloating some confluence pages with macros which is causing slow performance. 

Is there a for me to use the JavaScript API to count 1) The number of confluence macros currently used on the page 2) Get the names of these macros? 

I looked at the AJS API and saw that there is a "AJS.params" object but couldn't find any macro info in there. Also examined the AJS.MacroBrowser API and couldn't find anything useful..

Any ideas?

1 answer

0 votes
Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 1, 2017

If you have access to running a query against the database this will give you a list of your pages sorted by macro count per page.

select
C.CONTENTID,
S.SPACENAME,
C.TITLE,
(len(cast(B.BODY as nvarchar(max))) - len(replace(cast(B.BODY as nvarchar(max)), '<ac:structured-macro', ''))) / len('<ac:structured-macro') as MACROCOUNT
from CONTENT C
inner join BODYCONTENT B on C.CONTENTID = B.CONTENTID
inner join SPACES S on C.SPACEID = S.SPACEID
where C.PREVVER is null
and C.CONTENT_STATUS = 'current'
and C.CONTENTTYPE in ('PAGE', 'BLOGPOST')
order by MACROCOUNT desc

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events