Created
June 18, 2023 11:55
-
-
Save BrettWitty/36f821d76d60d00ab00276a08842de25 to your computer and use it in GitHub Desktop.
A way to hack around some of the HTML lost when Parchment interprets a HTML TADS 3 file as plaintext
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
function replaceText() { | |
$(".Style_normal").each(function() { | |
// Call each replacement once | |
var text = $(this).text(); | |
var hyphenCount = (text.match(/-/g) || []).length; | |
if (hyphenCount > 4) { | |
var replaced = text.replace(/-{4,}/g, "<hr/>"); | |
$(this).html(replaced); | |
} | |
var vip = (text.match(/MYWEBSITE/g) || []).length; | |
if (vip != 0) { | |
var replaced = text.replace('MYWEBSITE', "<a href=\"https://brettwitty.net\">LINK</a>"); | |
$(this).html(replaced); | |
} | |
}); | |
} | |
// Run the replacement function initially | |
replaceText(); | |
// Set up a MutationObserver | |
var observer = new MutationObserver(replaceText); | |
// Start observing the document with the configured mutations | |
observer.observe(document, { childList: true, subtree: true }); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>My game (Parchment)</title> | |
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0"> | |
<script src="https://iplayif.com/dist/web/jquery.min.js"></script> | |
<script src="https://iplayif.com/dist/web/ie.js" nomodule></script> | |
<script src="https://iplayif.com/dist/web/main.js" type="module"></script> | |
<link rel="stylesheet" href="https://iplayif.com/dist/web/web.css"> | |
<link rel="stylesheet" type="text/css" href="mycss.css"> | |
<script>parchment_options={story: 'mygame.t3'}</script> | |
<script src="hacks.js"></script> | |
</head> | |
<body> | |
<div id="gameport"> | |
<div id="about"> | |
<h1>Parchment</h1> | |
<p>is an interpreter for Interactive Fiction. <a href="https://github.com/curiousdannii/parchment">Find out more.</a></p> | |
<p>Find stories to play at the <a href="https://ifdb.org/">Interactive Fiction Database</a>.</p> | |
<p id="play-url"> | |
<input id="play-url-input" placeholder="Enter a URL of a story file" type="url"> | |
<button id="play-url-button">Go</button> | |
</p> | |
<p id="play-url-error"></p> | |
<label id="custom-file-upload" for="file-upload" tabindex="0" role="button"> | |
<p>Or, click here to play a story file on your device</p> | |
</label> | |
<input id="file-upload" type="file" style="display: none"/> | |
<noscript><p>Parchment requires Javascript. Please enable it in your browser.</p></noscript> | |
</div> | |
<div id="windowport"></div> | |
<div id="loadingpane" style="display:none;"> | |
<img src="https://iplayif.com/dist/web/waiting.gif" alt="LOADING"><br> | |
<em> Loading...</em> | |
</div> | |
<div id="errorpane" style="display:none;"><div id="errorcontent">...</div></div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment