A Wikipedia user script to automate common TfD operations
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // @TFDCLERK_HEADER_START@
  2. /*
  3. Copyright (C) 2015 Ben Kurtovic <ben.kurtovic@gmail.com>
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights to
  7. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  8. of the Software, and to permit persons to whom the Software is furnished to do
  9. so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in all
  11. copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  18. SOFTWARE.
  19. */
  20. // @TFDCLERK_HEADER_END@
  21. TFDClerk = {
  22. version: "@TFDCLERK_VERSION@",
  23. script_url: "https://en.wikipedia.org/wiki/User:The_Earwig/tfdclerk.js",
  24. author_url: "https://en.wikipedia.org/wiki/User_talk:The_Earwig",
  25. github_url: "https://github.com/earwig/tfdclerk",
  26. tfds: [],
  27. _api: new mw.Api(),
  28. _sysop: $.inArray("sysop", mw.config.get("wgUserGroups")) >= 0
  29. // TODO: access time?
  30. };
  31. TFDClerk.api_get = function(tfd, params, done, fail, always) {
  32. TFDClerk._api.get(params)
  33. .done(function(data) {
  34. if (done)
  35. done.call(tfd, data);
  36. })
  37. .fail(function(error) {
  38. if (fail)
  39. fail.call(tfd, error);
  40. else
  41. tfd._error("API query failure", error);
  42. })
  43. .always(function() {
  44. if (always)
  45. always.call(tfd);
  46. });
  47. };
  48. TFDClerk.install = function() {
  49. $("h4").each(function(i, elem) {
  50. var head = $(elem);
  51. if (head.next().hasClass("tfd-closed"))
  52. return;
  53. if (head.find(".mw-editsection").length == 0)
  54. return;
  55. var tfd = new TFD(TFDClerk.tfds.length, head);
  56. TFDClerk.tfds.push(tfd);
  57. tfd.add_hooks();
  58. });
  59. };