@@ -116,6 +116,7 @@ def get_init_scripts(self) -> List[str]:
116116 return super ().get_init_scripts () + [
117117 "registerGsftMainLoaded();" ,
118118 self ._get_remove_personalize_list_button_script (),
119+ self ._get_remove_context_menus_script (),
119120 ]
120121
121122 def _get_remove_personalize_list_button_script (self ):
@@ -136,6 +137,37 @@ def _get_remove_personalize_list_button_script(self):
136137 """
137138 return script
138139
140+ def _get_remove_context_menus_script (self ):
141+ """
142+ Removes context menus that appear on right-click in list views.
143+ These menus provide options that could be used to modify list data outside the task scope.
144+ """
145+ script = """
146+ function removeContextMenus() {
147+ waLog('Setting up context menu removal observer...', 'removeContextMenus');
148+ // Remove any existing context menus
149+ document.querySelectorAll('.context_menu').forEach((menu) => {
150+ menu.remove();
151+ });
152+ // Observe for new context menus being added
153+ const observer = new MutationObserver((mutations) => {
154+ mutations.forEach((mutation) => {
155+ mutation.addedNodes.forEach((node) => {
156+ if (node.nodeType === 1 && node.classList && node.classList.contains('context_menu')) {
157+ node.remove();
158+ waLog('Removed dynamically added context menu', 'removeContextMenus');
159+ }
160+ });
161+ });
162+ });
163+ observer.observe(document.body, { childList: true, subtree: true });
164+ waLog('Context menu observer active', 'removeContextMenus');
165+ }
166+
167+ runInGsftMainOnlyAndProtectByURL(removeContextMenus, '_list.do');
168+ """
169+ return script
170+
139171 def _get_visible_list (self , page : Page ):
140172 self ._wait_for_ready (page )
141173
0 commit comments