Skip to content

Instantly share code, notes, and snippets.

@yehgdotnet
Last active May 5, 2021 15:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yehgdotnet/d541c60eaa8b6cd9db71e7463ed1bb1c to your computer and use it in GitHub Desktop.
Save yehgdotnet/d541c60eaa8b6cd9db71e7463ed1bb1c to your computer and use it in GitHub Desktop.
Tampermonkey filesave dialog
A very fast and easy solution is to use FileSaver.js :
1) Add the following line into the ==UserScript== section of your Greasemonkey script
// @require https://raw.githubusercontent.com/eligrey/FileSaver.js/master/src/FileSaver.js
2) Add the 2 following lines of code to the GM script
var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
saveAs(blob, "hello world.txt");
This code example will display a dialog box to download a file named "hello world.txt" containing the text "Hello, world!". Just replace this by the file name and the text content of your choice !
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment