Skip to content

Instantly share code, notes, and snippets.

@videlais
Last active January 17, 2020 21:17
Show Gist options
  • Save videlais/8681773 to your computer and use it in GitHub Desktop.
Save videlais/8681773 to your computer and use it in GitHub Desktop.
No-click Twine (1.4) using jQuery
// First, create a reference to the Wikifier.createInternalLink function.
// (Internally, this is what Twine uses to connect passages together.
// It is the last step in parsing double-bracked content into links.)
var oldCreateInternalLink = Wikifier.createInternalLink;
// Then, create a new function that mimics its functionality.
Wikifier.createInternalLink = function(place, title) {
// By calling the old function, it returns
// the DOM element (the link) it was about to
// add to a passage.
link = oldCreateInternalLink(place, title);
// Using jQuery, add a listener for a 'mouseover' event.
// When it happens, call the anonymous function to
// 'Click' the link itself.
$(link).on('mouseover', function() {
this.click();
});
// Finally, return the link so that it can be added to a passage
return link;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment