🏠 Home 

s1新版麻将脸显示脚本

将新增的麻将脸代码转换成图片


安装此脚本?
  1. // ==UserScript==
  2. // @name s1新版麻将脸显示脚本
  3. // @namespace s1newmjfacejioben
  4. // @version 1.4
  5. // @description 将新增的麻将脸代码转换成图片
  6. // @author a simple s1 user
  7. // @match https://bbs.saraba1st.com/2b/*.html?**
  8. // @match https://bbs.saraba1st.com/2b/forum.php?mod=viewthread&tid=*?**
  9. // ==/UserScript==
  10. (function() {
  11. function replace(search,replacement){
  12. var xpathR###lt = document.evaluate(
  13. "//*/text()",
  14. document,
  15. null,
  16. XPathR###lt.ORDERED_NODE_ITERATOR_TYPE,
  17. null
  18. );
  19. var r###lts = [];
  20. // We store the r###lt in an array because if the DOM mutates
  21. // during iteration, the iteration becomes invalid.
  22. while(res = xpathR###lt.iterateNext()) {
  23. r###lts.push(res);
  24. }
  25. r###lts.forEach(function(res){
  26. res.textContent = res.textContent.replace(search,replacement);
  27. })
  28. }
  29. //上面那一段我也不懂什么意思,作用应该就是让replace仅限于可见文本。代码来源:http://bit.ly/2PR7uDG
  30. replace(/\{:1465_/g,'::mjlf')
  31. //这一段是普通分类的
  32. window.onload = function () {
  33. for (var i=0;i<12;i++){
  34. var id = 1691 + i;
  35. var zhengze = new RegExp("::mjlf" + id + ":}","g")
  36. var img = "<img src =\"http://mahjongface.tk/smiley/face/" + id + "\">";
  37. document.body.innerHTML = document.body.innerHTML.replace(zhengze, img);
  38. }//这一段是普通分类的
  39. document.body.innerHTML = document.body.innerHTML.replace(/\[f:215]/g, '<img src =\"http://mahjongface.tk/smiley/face/1696\">');
  40. document.body.innerHTML = document.body.innerHTML.replace(/\[f:214]/g, '<img src =\"http://mahjongface.tk/smiley/face/1699\">');
  41. }
  42. })();