Greasy Fork

Save GameFAQs as textfile

Save GameFAQs as textfile.

目前为 2017-04-21 提交的版本。查看 最新版本

// ==UserScript==
// @name        Save GameFAQs as textfile
// @description Save GameFAQs as textfile.
// @namespace   undefined
// @include     https://www.gamefaqs.com/*
// @version     0.1b
// @grant       none
// ==/UserScript==
(function () {
  var doc = document,
  text = doc.getElementById('faqtext').innerHTML,
  blob,
  a = doc.createElement('a'),
  filename = doc.URL.substr(doc.URL.lastIndexOf('/') + 1) + '.txt',
  p = doc.getElementsByTagName('p');
  if (text) {
    text = text.replace(/<\/?span.*?>/g, '');
    text = text.replace(/&lt;/g, '<');
    text = text.replace(/&gt;/g, '>');
    blob = new Blob([text], {
      endings: 'native'
    });
    a.href = URL.createObjectURL(blob);
    a.download = filename;
    a.textContent = 'Download Textfile';
    p[7].appendChild(doc.createElement('br'));
    p[7].appendChild(a);
    // doc.body.appendChild(a);
  }
}) ();