统计字数

奇了怪了,咋就有问题啊?

  1. // ==UserScript==
  2. // @name 统计字数
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 奇了怪了,咋就有问题啊?
  6. // @author You
  7. // @match https://www.tampermonkey.net/scripts.php
  8. // @include http://122.152.215.25:8088/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. $(".classtree-topbar").append($('<a class="calcText" style="'+
  15. 'top: 0px;'+
  16. 'position: absolute;'+
  17. 'background-position: 4px -1000px;'+
  18. 'font-size: 20px;'+
  19. 'text-align: center;'+
  20. 'cursor: pointer;'+
  21. '">字</a>'));
  22. $(".calcText").click(function(){
  23. var l = $("#ueditor_0").contents().find("body.view").text().trim().length || $("#document_body").text().trim().length;
  24. alert(l);
  25. });
  26. // Your code here...
  27. })();