Add some plain text to a javascript

This script works fine to save the current url to text file:

<script type="text/javascript">
setTimeout("create(window.location.href, 'file.html', 'text/plain')");
function create(text, name, type) {
  var dlbtn = document.getElementById("save");
  var file = new Blob([text], {type: type});
  dlbtn.href = URL.createObjectURL(file); = name;
<a href="javascript:void(0)" id="save"><button>SAVE</button></a>

But I need the finished file to look like below, how do I add the extra code to the file?

  <script type="text/javascript">
window.location.href = "CURRENT URL GOES HERE";

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

What do you mean by the finished file?
Why do you download the file at first?

This seems to be a XY problem. What are you really trying to achieve?