GF enhance new version upload

Select Syntax highlight (enhanced editor) and resize the code box by default when uploading a script

当前为 2016-08-04 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GF enhance new version upload
  3. // @author wOxxOm
  4. // @license MIT License
  5. // @description Select Syntax highlight (enhanced editor) and resize the code box by default when uploading a script
  6. // @namespace wOxxOm.scripts
  7. // @version 1.0.0
  8. // @include https://greasyfork.org/*scripts/*/versions/new*
  9. // @include https://greasyfork.org/*script_versions/new*
  10. // @run-at document-start
  11. // @require https://greasyfork.org/scripts/12228/code/setMutationHandler.js
  12. // ==/UserScript==
  13.  
  14. setMutationHandler(document, '#script_version_code', function(nodes) {
  15. this.disconnect();
  16.  
  17. var area = nodes[0];
  18. var bounds = area.getBoundingClientRect();
  19. area.style.height = Math.max(200, innerHeight - bounds.top + 10) + 'px';
  20. area.style.marginBottom = innerHeight + 'px';
  21.  
  22. var scriptInfo = document.getElementById('script-info') || document.querySelector('header').nextElementSibling;
  23. scrollBy(0, scriptInfo.getBoundingClientRect().top);
  24.  
  25. document.getElementById('enable-source-editor-code').click();
  26.  
  27. setTimeout(function() {
  28. scrollBy(0, scriptInfo.getBoundingClientRect().top);
  29. }, 0);
  30. });