Skip to content

Instantly share code, notes, and snippets.

@surajitbasak109
Created October 5, 2018 16:17
Show Gist options
  • Save surajitbasak109/15043e3abf0259c0a109a247004c06c1 to your computer and use it in GitHub Desktop.
Save surajitbasak109/15043e3abf0259c0a109a247004c06c1 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Download in a text file
// @namespace https://www.youtube.com/user/surajitbasak109
// @version 1
// @description This script downloads webpage in a text file
// @author Surajit Basak
// @match http*://*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var a = document.createElement('a');
document.body.appendChild(a);
a.textContent = 'Download in a text format';
a.setAttribute('style', 'position: fixed; top: 0px; right: 0px; border-radius: 15px; width: 300px; padding: 10px 12px; background-color: darkred; color: white; z-index: 99999');
var blob = new Blob([document.body.innerText], {type: 'text/plain'});
var url = window.URL.createObjectURL(blob);
a.href = url;
a.download = document.title + '.txt';
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment