Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VCLWarningScriptTamperMonkey
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
icommonsCRC
VCLWarningScriptTamperMonkey
Commits
ea129a01
Commit
ea129a01
authored
9 months ago
by
icommonsCRC
Browse files
Options
Downloads
Patches
Plain Diff
VCL Warning Script
parent
c33601d0
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
VCLScript.js
+77
-0
77 additions, 0 deletions
VCLScript.js
with
77 additions
and
0 deletions
VCLScript.js
0 → 100644
+
77
−
0
View file @
ea129a01
// ==UserScript==
// @name VM Warning Dialog Script with Specific Fullscreen Button
// @namespace http://tampermonkey.net/
// @version 0.6
// @description Show a warning dialog and click specific fullscreen button for VM
// @match https://your-vm-site-url.com/*
// @grant none
// ==/UserScript==
(
function
()
{
'
use strict
'
;
function
debug
(
message
)
{
console
.
log
(
'
VM Warning Script Debug:
'
+
message
);
}
function
clickFullscreenButton
()
{
debug
(
'
Attempting to click fullscreen button
'
);
// Target the specific fullscreen button based on its structure
var
fullscreenButton
=
document
.
querySelector
(
'
span.ms-Button-flexContainer[data-automationid="splitbuttonprimary"] i[data-icon-name="FullScreenRegular"]
'
);
if
(
fullscreenButton
)
{
// Click the parent button element, not just the icon
var
parentButton
=
fullscreenButton
.
closest
(
'
button
'
);
if
(
parentButton
)
{
parentButton
.
click
();
debug
(
'
Fullscreen button clicked
'
);
}
else
{
debug
(
'
Parent button not found
'
);
}
}
else
{
debug
(
'
Fullscreen button not found
'
);
}
}
function
showWarningDialog
()
{
debug
(
'
Showing warning dialog
'
);
var
dialog
=
document
.
createElement
(
'
div
'
);
dialog
.
id
=
'
vm-warning-dialog
'
;
dialog
.
style
.
cssText
=
`
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: white;
padding: 20px;
border: 2px solid black;
z-index: 10000;
text-align: center;
`
;
dialog
.
innerHTML
=
`
<h2>Warning</h2>
<p>Data is not saved after this session. Please use OneDrive to save your files.</p>
<button id="okButton">OK</button>
`
;
document
.
body
.
appendChild
(
dialog
);
document
.
getElementById
(
'
okButton
'
).
addEventListener
(
'
click
'
,
function
()
{
dialog
.
remove
();
debug
(
'
Dialog closed
'
);
// Attempt to click the fullscreen button
setTimeout
(
clickFullscreenButton
,
1000
);
// Delay to ensure page is ready
});
}
window
.
addEventListener
(
'
load
'
,
showWarningDialog
);
// Fallback
setTimeout
(
function
()
{
if
(
!
document
.
getElementById
(
'
vm-warning-dialog
'
))
{
debug
(
'
Dialog not shown after load event, attempting to show now
'
);
showWarningDialog
();
}
},
2000
);
})();
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment