greasyfork-org / greasyfork

An online repository of user scripts.
https://greasyfork.org
GNU General Public License v3.0
1.44k stars 435 forks source link

hope allow @require url support Data URLs #1084

Closed lisonge closed 2 years ago

lisonge commented 2 years ago
// ==UserScript==
// @name               example
// @namespace          https://github.com/lisonge
// @version            1.0.1
// @author             lisonge
// @match              https://i.songe.li/
// @require            https://cdn.jsdelivr.net/npm/vue@3.0.0/dist/vue.global.prod.js
// @require            data:application/javascript,%3Bwindow.Vue%3DVue%3B
// @require            https://unpkg.com/element-plus@2.2.15/dist/index.full.js
// ==/UserScript==

// `data:application/javascript,` + encodeURIComponent(`;window.Vue=Vue;`)

because vue use iife export, element-plus use umd, they can not both work in Tampermonkey/Violentmonkey window scope

full detail see vite-plugin-monkey#5

The simplest solution is that add a @require url to set window.Vue to scope.Vue after vue require url

JasonBarnabe commented 2 years ago

I don't understand the purpose of this. Can you explain further? Is this something already supported by user script managers like Tampermonkey?

lisonge commented 2 years ago

Tampermonkey/Violentmonkey support // @require data:application/javascript,%3Bwindow.Vue%3DVue%3B

lisonge commented 2 years ago

image image

can not work

lisonge commented 2 years ago

image image

can work

lisonge commented 2 years ago

image

but // @require data:application/javascript,%3Bwindow.Vue%3DVue%3B is not allowed at greasyfork

lisonge commented 2 years ago

Do you understand what I mean ?

lisonge commented 2 years ago

@JasonBarnabe hello, Could you please give me an accurate reply?

JasonBarnabe commented 2 years ago

data URI @requires are now allowed.

lisonge commented 2 years ago

ok, thanks