A Wikipedia user script to automate common TfD operations
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

tfdclerk.js 2.3 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Templates for discussion clerk script by [[User:The Earwig]]
  2. // Version: @TFDCLERK_VERSION_FULL@
  3. // Development and bug reports: https://github.com/earwig/tfdclerk
  4. // To install, add:
  5. // importScript("User:The Earwig/tfdclerk.js"); // [[User:The Earwig/tfdclerk.js]]
  6. // to [[Special:MyPage/common.js]] or [[Special:MyPage/skin.js]]
  7. /*
  8. Copyright (C) 2015 Ben Kurtovic <ben.kurtovic@gmail.com>
  9. Permission is hereby granted, free of charge, to any person obtaining a copy
  10. of this software and associated documentation files (the "Software"), to deal
  11. in the Software without restriction, including without limitation the rights to
  12. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  13. of the Software, and to permit persons to whom the Software is furnished to do
  14. so, subject to the following conditions:
  15. The above copyright notice and this permission notice shall be included in all
  16. copies or substantial portions of the Software.
  17. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  23. SOFTWARE.
  24. */
  25. // <nowiki>
  26. var dependencies = [
  27. "mediawiki.api",
  28. "mediawiki.ui",
  29. "mediawiki.util",
  30. "jquery.ui.core"
  31. ];
  32. var is_tfd_page = function() {
  33. return mw.config.get("wgAction") == "view" &&
  34. mw.config.get("wgIsProbablyEditable") == true &&
  35. mw.config.get("wgRevisionId") == mw.config.get("wgCurRevisionId") &&
  36. mw.config.get("wgNamespaceNumber") == 4 && (
  37. mw.config.get("wgTitle") == "Templates for discussion" ||
  38. mw.config.get("wgTitle").indexOf("Templates for discussion/Log/2") == 0);
  39. };
  40. if (is_tfd_page()) {
  41. mw.loader.using(dependencies, function() {
  42. /* Main script starts here */
  43. @TFDCLERK_INCLUDE:main.js@
  44. @TFDCLERK_INCLUDE:util.js@
  45. @TFDCLERK_INCLUDE:tfd.js@
  46. @TFDCLERK_INCLUDE:tfd_close.js@
  47. @TFDCLERK_INCLUDE:tfd_relist.js@
  48. $(TFDClerk.install);
  49. /* Main script ends here */
  50. });
  51. }
  52. // </nowiki>