PrintMoqups

Make Moqups project printable. Free!

当前为 2015-11-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name PrintMoqups
  3. // @version 0.2
  4. // @author FireAwayH
  5. // @namespace FireAwayH
  6. // @match https://app.moqups.com/*
  7. // @grant none
  8. // @description Make Moqups project printable. Free!
  9. // @run-at document-end
  10. // ==/UserScript==
  11. /* jshint -W097 */
  12. 'use strict';
  13.  
  14. var init = function(){
  15. var menu = document.getElementById("account-menu");
  16. var printIt = document.createElement("a");
  17. menu.appendChild(printIt);
  18. printIt.outerHTML = '<a href="#" class="upgrade-btn mq-btn" onclick="printIt();">print it</a>';
  19. var insertScript = document.createElement("script");
  20. insertScript.id = "printIt";
  21. insertScript.innerHTML =
  22. "var needPrint = $('.canvas-svg:eq(0)').find('svg:eq(0)')[0];\
  23. var insertStyle = document.createElement('link');\
  24. var title = document.createElement('title');\
  25. insertStyle.setAttribute('rel', 'stylesheet');\
  26. insertStyle.setAttribute('href', 'https://appstatic.moqups.com/css/2.2.39/moqups.css');\
  27. var printIt = function(){\
  28. if(!needPrint){\
  29. needPrint = $('.canvas-svg:eq(0)').find('svg:eq(0)')[0];\
  30. }\
  31. var newWindow = window.open();\
  32. var titleText = $('title').html();\
  33. title.innerHTML = titleText;\
  34. newWindow.document.head.appendChild(insertStyle);\
  35. newWindow.document.head.appendChild(title);\
  36. newWindow.document.body.innerHTML = needPrint.outerHTML;\
  37. newWindow.document.body.setAttribute('style','overflow:scroll');\
  38. }\
  39. ";
  40.  
  41.  
  42. document.body.appendChild(insertScript);
  43. }
  44.  
  45. init();