NF_NoPreviewAndMusicXML

Sets'preview=false' on halleonard note flight viewer and adds a DL button for music.XML

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
  1. // ==UserScript==
  2. // @name NF_NoPreviewAndMusicXML
  3. // @namespace http://halleonard.com/
  4. // @version 1.0
  5. // @description Sets'preview=false' on halleonard note flight viewer and adds a DL button for music.XML
  6. // @author cw2k
  7. // @match *://*.halleonard.com/nf/*
  8. // @match *://sheetmusicdirect.com
  9. // @grant none
  10. // ==/UserScript==
  11. //
  12. // Quickens the way to get stuff from http://sheetmusicdirect.com
  13. // ... and saves money - since now
  14. // -> The preview will contain ALL pages !
  15. // -> you'll get the music.XML that's the key for your creativity
  16. // the 'source code' that'll enable you to much more than
  17. // just print out the sheet
  18. //
  19. //
  20. // So what can you do with the music.XML?
  21. // -> load it in Muscore, Finale, Capella, Sibelius Guitar Pro or what
  22. // even you do or will do your compositions or music sheet layouts.
  23. //
  24. // If you don't know any of these yet I promote 'Musecore'
  25. // it's the only one that is free & open source.
  26. // And to me that's open source is the only 'thing' that can really 'live'
  27. // everybody can take part in it and contributes its little part.
  28. // Just look how powerfull Wikipedia and Linux have became!
  29.  
  30. (function() {
  31. 'use strict';
  32.  
  33. // Get Noteflight Viewer Iframe
  34. var nf = $('iframe#noteflight-viewer');
  35. // parse .src params
  36. var url = new URL(nf[0].src);
  37. var params = url.searchParams;
  38.  
  39. debugger;
  40. // query preview
  41. if ( params.has('preview') ) {
  42. try {
  43. console.info('Wow!');
  44.  
  45. // set preview to false
  46. params.set('preview','false');
  47. //params.set('hidePlaybackControls','false');
  48.  
  49. // set copy .src string back into DOM
  50. nf[0].src=url.toString();
  51.  
  52. var musicXML = params.get('url');
  53. console.info( musicXML );
  54. console.info('^- Es la curacao.');
  55. } catch(e) {
  56. console.error("NF_NoPreviewAndMusicXML::setPreviewFalse " + e);
  57. }
  58. setMusicXML( musicXML );
  59. }
  60. // https://haldms.halleonard.com/nfviewer-20170313/?url=%2F%2Fhalleonard-musicxml.s3.amazonaws.com...
  61. //...
  62. // C.isPreview = function() {
  63. // return C.scoreEditor.viewer() &&
  64. // "true" ==
  65. // C.scoreEditor.viewerParams.preview ||
  66. // C.score().editor_configuration.preview()
  67. // }
  68.  
  69. console.info('Chao.');
  70.  
  71. function setMusicXML( musicXML ) {
  72.  
  73. if (musicXML.length) {
  74.  
  75. try {
  76. //debugger;
  77.  
  78. var btnGrp_DL = $('.btn-group--download');
  79. var btn_DL = $("button",btnGrp_DL);
  80. //var b=a.a;
  81. var btnGrp_DLxml = btnGrp_DL.clone(true);
  82. var btn_DLxml = $("button",btnGrp_DLxml);
  83.  
  84. btn_DLxml.attr( "data-tooltip", "Download MusicXML" ) ;
  85. btn_DLxml.attr( "data-action", "" ) ;
  86. btn_DLxml.children().text( " xml" ) ;
  87. btn_DLxml.bind( "click", function(a) {
  88. debugger;
  89. //scoreView = new NFClient.ScoreView(NF_ID,"",options)
  90. //document.write( scoreView.getMusicXML().toString() ) ;
  91. window.open( musicXML, "_blank" );
  92. });
  93. btn_DLxml.attr( "title", "Bugfix/ Workaround (Press ctrl + s to finally save the xml)");
  94.  
  95. btnGrp_DL.append( btnGrp_DLxml );
  96.  
  97. } catch(e){
  98. console.error(e);
  99. setMusicXML_fallback ( musicXML );
  100. }
  101.  
  102. }
  103.  
  104. }
  105. function setMusicXML_fallback ( musicXML ) {
  106. try {
  107. var newLink = document.createElement('a');
  108. newLink.text = "Download MusicXML";
  109. newLink.href = musicXML;
  110. newLink.setAttribute( 'target', "_blank");
  111. newLink.title = "Bugfix/ Workaround (Press ctrl + s to finally save the xml)";
  112. newLink.setAttribute(
  113. 'style',
  114. "position: absolute; \
  115. left: 50%; \
  116. z-index: 1;"
  117. );
  118. newLink.setAttribute( 'download' );//, "Music.XML" );
  119.  
  120. document.body.prepend(newLink);
  121. } catch(e){
  122. console.error(e);
  123. alert("Error in NF_NoPreviewAndMusicXML::setMusicXML()" + e );
  124. }
  125. }
  126.  
  127. }
  128. )();
  129.  
  130. // Louis Armstrong: St. Louis Blues (https://www.sheetmusicdirect.com/se/ID_No/71657/Product.aspx)
  131. // P R E V I E W: https://haldms.halleonard.com/nf/preview/146/134671
  132. //
  133. // P E R F O R M: https://haldms.halleonard.com/nf/viewer/1B413CC80CB84DC5A50F2F240689F9F5/perform
  134. // P R I N T : https://haldms.halleonard.com/nf/download/B10F82F562A342BA96F200AD50C7DADD/inline
  135. // D O W N L O A D: https://haldms.halleonard.com/nf/download/B10F82F562A342BA96F200AD50C7DADD
  136. // https://www.sheetmusicdirect.com/de-DE/Account/PrintScore.aspx?ID_No=71657
  137. // ^- At this level not attackable.
  138. //
  139. //P R I N T
  140. // https://haldms.halleonard.com/nf/download/87B64E64EA9B4B6C9938862194057A1B/inline
  141. // direct server redirect via Respond - 'Location:' to
  142. // https://halleonard-pdf-restricted.s3.amazonaws.com/personalized/87B64E64EA9B4B6C9938862194057A1B.pdf?response-content-disposition=attachment%3B%20filename%3D%22st-louis-blues.pdf%22&response-content-type=application%2Fpdf&AWSAccessKeyId=AKIAJZU27QVNIHBBIOIQ&Expires=1522703840&Signature=1DRgozvCHWBzRJlGDgfBky3rotU%3D
  143. //
  144. // P E R F O R M
  145. // https://haldms.halleonard.com/nf/viewer/505565DA200642DA8EAA5C7DD0837730/perform
  146. // https://halleonard-musicxml-restricted.s3.amazonaws.com/sheetmusic-full-gz/HL_DDS_0000000000520893.xml.gz?AWSAccessKeyId=AKIAJZU27QVNIHBBIOIQ&Expires=1522699324&Signature=mfJt8EddKmDtjB3eP4vqB0kdaN0%3D
  147. // GET /sheetmusic-full-gz/HL_DDS_0000000000520893.xml.gz?AWSAccessKeyId=AKIAJZU27QVNIHBBIOIQ&Expires=1522699324&Signature=mfJt8EddKmDtjB3eP4vqB0kdaN0%3D
  148. // Host: halleonard-musicxml-restricted.s3.amazonaws.com
  149. //
  150. // AWSAccessKeyId = Amazon Web Services AccessKeyId
  151. // Expires = seconds since epoch (1970-01-01T00:00:00Z)
  152. // Signature = HMAC SHA256
  153. // ToCreate: we need
  154. // 1. the message: Known it's
  155. //GET/x0a/x0a/x0a[Expires]/x0a/halleonard-musicxml-restricted/sheetmusic-full-gz/HL_DDS_0000000000520893.xml.gz
  156. // 2. The Algo - kinda known look at the 'Amazon Web Services Docu'
  157. // 3. the secret key - PROBLEM since it is unknown