Scribd Print and Download

Changes "Upload" link to open a printable viewer (print to PDF)

当前为 2015-12-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Scribd Print and Download
  3. // @description Changes "Upload" link to open a printable viewer (print to PDF)
  4. // @author Inserio
  5. // @include http://*.scribd.com/doc/*
  6. // @include https://*.scribd.com/doc/*
  7. // @version 1.6
  8. // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
  9. // @namespace https://greasyfork.org/users/11878
  10. // ==/UserScript==
  11.  
  12. var new_link;
  13.  
  14. $('script').html(function (i, text) {
  15. var idRegex = /"id":(\d{6,})/i;
  16. var keyRegex = /"access_key":"(key[-\w\d]*)"/i;
  17. var id = idRegex.exec(text);
  18. var key = keyRegex.exec(text);
  19. if (id !== null && key !== null && id !== undefined && key !== undefined)
  20. new_link = "http://d1.scribdassets.com/ScribdViewer.swf?document_id=" + id[1] + "&access_key=" + key[1];
  21. // if (new_link !== undefined)
  22. // return text.replace(/https?:\/\/www\.scribd\.com\/upload-document/gi, new_link);
  23. // Matches the "Upload" link on the page.
  24. // Click it to open the new page in a viewer that will allow printing to PDF
  25. });
  26.  
  27. $('div').html(function (i, text) {
  28. if (new_link !== undefined)
  29. return text.replace(/https?:\/\/www\.scribd\.com\/upload-document/gi, new_link);
  30. });