lisonge / vite-plugin-monkey

A vite plugin server and build your.user.js for userscript engine like Tampermonkey, Violentmonkey, Greasemonkey, ScriptCat

Repository from Github https://github.comlisonge/vite-plugin-monkeyRepository from Github https://github.comlisonge/vite-plugin-monkey

Auto-grant works only for GM_API

7nik opened this issue · comments

commented

The following code

import { monkeyWindow } from "$";

if (monkeyWindow.onurlchange === null) {
    monkeyWindow.addEventListener("urlchange", console.log);
}
monkeyWindow.focus();
monkeyWindow.close();
// @ts-expect-error
monkeyWindow.unsafeWindow.test = 42;

built with default config outputs

// ==UserScript==
// @name       us-test
// @namespace  npm/vite-plugin-monkey
// @version    0.0.0
// @author     monkey
// @icon       https://vitejs.dev/logo.svg
// @match      https://www.google.com/
// ==/UserScript==

(function () {
  'use strict';

  var _monkeyWindow = /* @__PURE__ */ (() => window)();
  if (_monkeyWindow.onurlchange === null) {
    _monkeyWindow.addEventListener("urlchange", console.log);
  }
  _monkeyWindow.focus();
  _monkeyWindow.close();
  _monkeyWindow.unsafeWindow.test = 42;

})();

which doesn't contain any of corresponding @grant's.