Save GameFAQs as textfile

Save GameFAQs as textfile.

目前為 2017-04-21 提交的版本,檢視 最新版本

  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.1b
  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. if (text) {
  17. text = text.replace(/<\/?span.*?>/g, '');
  18. text = text.replace(/&lt;/g, '<');
  19. text = text.replace(/&gt;/g, '>');
  20. blob = new Blob([text], {
  21. endings: 'native'
  22. });
  23. a.href = URL.createObjectURL(blob);
  24. a.download = filename;
  25. a.textContent = 'Download Textfile';
  26. p[7].appendChild(doc.createElement('br'));
  27. p[7].appendChild(a);
  28. // doc.body.appendChild(a);
  29. }
  30. }) ();