Last active
June 16, 2023 17:58
-
-
Save cubimon/f022dbe25c4cd6198bb80cc9eb38ef24 to your computer and use it in GitHub Desktop.
GeForce NOW Fullscreen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name GeforceNow Fullscreen | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://play.geforcenow.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=geforcenow.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function log(message) { | |
console.log(`cubigfn: ${message}`); | |
} | |
function fullscreenchanged(event) { | |
//event.stopImmediatePropagation(); | |
if (document.fullscreenElement) { | |
log( | |
`Element: ${document.fullscreenElement.id} entered fullscreen mode.` | |
); | |
document.exitFullscreen(); | |
} else { | |
log("Leaving fullscreen mode, stop propa gation"); | |
event.stopImmediatePropagation(); | |
} | |
} | |
document.addEventListener("fullscreenchange", fullscreenchanged, true); | |
const oldCreateElement = document.createElement; | |
document.createElement = function(tagName, options) { | |
const result = oldCreateElement.call(this, tagName, options); | |
if (arguments[0] !== 'video') { | |
return result; | |
} | |
console.log('cubigfn: found video'); | |
// requestFullscreen | |
const oldRequestFullscreen = result.requestFullscreen; | |
result.oldRequestFullscreen = oldRequestFullscreen; | |
result.requestFullscreen = function() { | |
log('requesting fullscreen on element'); | |
log(result); | |
log(arguments); | |
return oldRequestFullscreen.call(this); | |
//return new Promise((resolve, reject) => { | |
// document.fullscreenElement = result; | |
// resolve(); | |
//}); | |
}; | |
// lockapi keeps mouse cursor at start position, without moving it | |
// requestPointerLock | |
const oldRequestPointerLock = result.requestPointerLock; | |
result.oldRequestPointerLock = oldRequestPointerLock; | |
result.requestPointerLock = function(options) { | |
log('locking pointer on element'); | |
log(result); | |
log(options); | |
//return oldRequestPointerLock.call(this, options); | |
return new Promise((resolve, reject) => { | |
resolve(); | |
}); | |
} | |
result.addEventListener('mouseenter', (event) => { | |
log('mouse enter'); | |
log(event); | |
//result.exitPointerLock(); | |
//result.requestPointerLock({unadjustedMovement: true}); | |
//result.requestPointerLock(); | |
event.x; | |
event.y; | |
event.pageX; | |
event.pageY; | |
event.screenX; | |
event.screenY; | |
/*setTimeout(() => { | |
log('timeout'); | |
window.video.click(); | |
const evt = new MouseEvent('click', { | |
bubbles: true, | |
cancelable: true, | |
clientX: 10, | |
clientY: 0, | |
}); | |
window.video.dispatchEvent(evt); | |
}, 1000);*/ | |
}); | |
result.addEventListener('mouseleave', (event) => { | |
log('mouse leave'); | |
log(event); | |
}); | |
const videochange = (mutationList, observer) => { | |
log("change"); | |
if (result.style.cursor === 'none') { | |
window.video.style.cursor = null; | |
} | |
} | |
const observer = new MutationObserver(videochange); | |
observer.observe(result, {attributes: true}); | |
window.video = result; | |
return result; | |
}; | |
document.oldCreateElement = oldCreateElement; | |
console.clear = () => {}; | |
addEventListener('mousemove', (event) => { | |
log('mouse move event'); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment