Closed virtadpt closed 3 years ago
Hi @virtadpt! The default behavior for konami-js, when you pass a URL in as a parameter, is to redirect the user there. If you'd like to have it do something else you can pass a callback function instead. Something like this:
const kitteh = new Konami(() => { const script = document.createElement('script'); script.type = 'text/javascript'; script.src = '"https://webneko.net/n20171213.js'; document.getElementsByTagName('head')[0].appendChild(script); });
I'm not quite sure how the Webneko script works, so you might need to take additional steps after the file loads.
Let me know if that helps?
I just gave it a try on my dev server and it didn't seem to work. Nothing in my dev server output (which displays all requests made for debugging purposes. However in the Firefox Javascript console I get the following messages:
A call to document.write() from an asynchronously-loaded external script was ignored.
Use of captureEvents() is deprecated. To upgrade your code, use the DOM 2 addEventListener()
method. For more help http://developer.mozilla.org/en/docs/DOM:element.addEventListener
And no appearance of webneko, unfortunately.
Ah, it looks like Webneko uses document.write()
to insert something into the page. That means you're probably not going to be able to dynamically load that script after the page is already loaded, at least not without copying and rewriting it a bit, against the will of the author.
A possibly less satisfying, hacky way to do it though might be to:
I looked at the demo site and I think this should work:
// hide Neko right after you load it
document.querySelector('#layerNeko0').style.display = "none"
// Inside the Konami-JS callback, unhide it:
const kitteh = new Konami(() => {
document.querySelector('#layerNeko0').style.display = "block";
});
Does that make sense?
It does make sense, and I thank you. I was working with the author of Webneko and he came up with a simpler method: https://github.com/virtadpt/pelican-html5up-striped/blob/master/templates/index.html#L46
Makes sense! Thanks for using this silly project :)
Hi. Would it be possible to use konami-js to pull in and run another Javascript file sourced from a URL? Here is what I tried, but all it does is display the Javascript code in the browser tab when I run it:
Note: I can redirect to a different URL entirely without trouble.
I don't want to pull down a copy of the file and self-host it because the author of Webneko asks folks to not do that, and I want to respect his wishes.