最近搜索
没有最近搜索

Goldylox
已加入2021年10月22日
·
最后活动2021年10月22日
关注
0
关注者
0
活动总数
1
投票
0
订阅
0
活动概览
标记
文章
帖子
社区评论
文章评论
活动概览
的最新活动 Goldylox
Goldylox 进行了评论,
Hey all!
Just to chime in on a more secure way for what Colin suggested, instead of hiding and showing alone, there's a way to remove element by class so it doesn't show at all, not even in Inspect. This way it can't be bypassed (or at least is incredibly more difficult to bypass if not impossible?).
In javascript:
// Remove or show div html based on role
if (HelpCenter.user.role=="end_user"){
const elements = document.getElementsByClassName('internal');
while(elements.length > 0){
elements[0].parentNode.removeChild(elements[0]);
}
}
if (HelpCenter.user.role=="anonymous"){
const elements = document.getElementsByClassName('internal');
while(elements.length > 0){
elements[0].parentNode.removeChild(elements[0]);
}
}
if (HelpCenter.user.role=="agent"){
var elements = document.getElementsByClassName('internal');
for (var i = 0; i < elements.length; i ++) {
elements[i].style.display = 'block';
}
}
if (HelpCenter.user.role=="manager"){
var elements = document.getElementsByClassName('internal');
for (var i = 0; i < elements.length; i ++) {
elements[i].style.display = 'block';
}
}
css code, hidden by default because there's a weird thing where when the page is refreshed the internal notes are displayed for everyone for a split second before the javascript removes it (puts a red outline and light red background so it stands out as being internal, as well as writes Internal Notes at the top of the box):
/* internal note styling */
.internal:before {
content:"Internal Notes \a";
font-size:22px;
color:red;
white-space: pre;
}
.internal {
background-color: #ffeeee;
border: 1px solid #ff0101;
border-radius: 5px;
text-align: left;
padding-top: 7px;
padding-bottom: 7px;
padding-left: 14px;
padding-right: 14px;
position: relative;
display: none;
}
Then put
This will hide internal notes by default, remove them from the HTML if the user is an End User or Anonymous, and change display to block if the user is an Agent or Manager. Internal notes can be used multiple times in the same article with this code. Hope this helps!
查看评论 · 已于 2021年7月22日 发布 · Goldylox
0
关注者
0
投票
0
评论