Save GameFAQs as textfile

Save GameFAQs as textfile.

目前为 2017-04-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Save GameFAQs as textfile
  3. // @description Save GameFAQs as textfile.
  4. // @namespace undefined
  5. // @include https://www.gamefaqs.com/*
  6. // @version 0.1
  7. // @grant none
  8. // ==/UserScript==
  9. (function () {
  10. var doc = document,
  11. text = doc.getElementById('faqtext').innerHTML,
  12. blob,
  13. a = doc.createElement('a'),
  14. filename = doc.URL.substr(doc.URL.lastIndexOf('/') + 1) + '.txt',
  15. p = doc.getElementsByTagName('p'),
  16. p2 = p[p.length - 3];
  17. if (text) {
  18. text = text.replace(/<\/?span.*?>/g, '');
  19. blob = new Blob([text], {
  20. endings: 'native'
  21. });
  22. a.href = URL.createObjectURL(blob);
  23. a.download = filename;
  24. a.textContent = 'Download Textfile';
  25. p2.appendChild(doc.createElement('br'));
  26. p2.appendChild(a);
  27. // doc.body.appendChild(a);
  28. }
  29. }) ();