MAL counter for Profile and Blog

A character counter for Profile and Blog editing

当前为 2015-03-23 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name MAL counter for Profile and Blog
  3. // @namespace MAL
  4. // @include http://myanimelist.net/editprofile.php
  5. // @include http://myanimelist.net/myblog.php*
  6. // @description A character counter for Profile and Blog editing
  7. // @version 1
  8. // ==/UserScript==
  9.  
  10. function xpath(query, object) {
  11. if(!object) var object = document;
  12. return document.evaluate(query, object, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  13. }
  14.  
  15. var warningText = "Characters left: ";
  16. var charactersLimit = 65535;
  17.  
  18. var allElements = xpath("//textarea[@name='entry_text'][@class='textarea'] | " + "//textarea[@class='textarea'][@name='profile_aboutme']");
  19. if(allElements.snapshotLength > 0) {
  20. textarea = allElements.snapshotItem(0);
  21.  
  22. var div1 = document.createElement("div");
  23. div1.style="margin: 0px; margin-top:10px; margin-bottom:5px";
  24. div1.align ="Left";
  25. div1.id = "characterLimit";
  26. div1.innerHTML = warningText + (charactersLimit - textarea.value.length);
  27. div1.style.display = "block";
  28.  
  29. textarea.parentNode.insertBefore(div1, textarea.nextSibling);
  30. if (div1.nextSibling.tagName == "BR") {
  31. div1.nextSibling.style.display = "none";
  32. }
  33.  
  34. textarea.addEventListener('keyup', function(e) {
  35. div1.innerHTML = warningText + (charactersLimit - textarea.value.length);
  36. }, true);
  37. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址