How to get plugin parameters without knowing your filename

Edge natively supports it, for the other this polyfill should work(I have to test it though) https://github.com/JamesMGreene/document.currentScript/blob/master/dist/document.currentScript.js ;

Fun fact is that I discover this api because I was looking for an equivalent of IE readyState 🙂
I updated the OP with a shorter version of your solution, as already posted in your thread. it might be risky, since as a plugin writer, you can't always know where your plugin will be used and cross-browser compatibility can be an issue. Adding the polyfill seems too much work, just to get parameters, but it's good to have options to choose from.


If you are making plugins for yourself or are working in a team, you can use the "currentScript" solution, since it's easier to implement and doesn't need an identifier in your plugin's description. For full compatibility, i would stick to the other solution, as it's guarenteed to work independently from the browser in use.


/edit: Shortened the new solution and modified it to not use lookahead, but a normal match.
I updated the OP with a shorter version of your solution, as already posted in your thread. it might be risky, since as a plugin writer, you can't always know where your plugin will be used and cross-browser compatibility can be an issue. Adding the polyfill seems too much work, just to get parameters, but it's good to have options to choose from.


If you are making plugins for yourself or are working in a team, you can use the "currentScript" solution, since it's easier to implement and doesn't need an identifier in your plugin's description. For full compatibility, i would stick to the other solution, as it's guarenteed to work independently from the browser in use.


/edit: Shortened the new solution and modified it to not use lookahead, but a normal match.
By cross-browser, are there any in particular that you're thinking about?


Like, even with IE, how old are you talking?
So what is the best option available so far, if I want something that only requires a couple of lines, works on ALL platforms/browsers, and doesn't require additional plugins to work? I'm thinking it's still probably the first or second option you came up with.
The option using description works everywhere. The "new" option uses document.currentScript, which, according to Mozilla, is not supported in IE at all: https://developer.mozilla.org/de/docs/Web/API/document/currentScript
Can someone make a video if someone can do it?
@sblackburn I don't think that that would be a good idea - this is about coding, which means reading and writing code - there have been dozens of failed tries to show that by videos, and the problems range from the watchers misreading the code due to bad video quality over the video not explaining some parts due to length limitations to people simply not getting the point because the videos going too fast (reading is better for complex material as it allows you to set your own speed.


That said, this idea has basically been outdated by the community - instead of every plugin writer trying to get his brain around this coding, they simply say "don't rename the plugin file". Because if you know the name of the plugin file (which you are writing yourself after all), none of this is neccessary.
I'm clearly too dumb to understand what I need to do, which is a shame because I really need this one. Does anyone have step for step screenshots?

Original thread: https://forums.rpgmakerweb.com/threads/how-to-get-plugin-parameters-without-knowing-your-filename.47591/