TianyaFilter

天涯社区楼层计数、过滤指定用户的回贴。

  1. // ==UserScript==
  2. // @name TianyaFilter
  3. // @namespace http://bbs.tianya.cn/post-stocks-216255-1.shtml
  4. // @version 1.2.5
  5. // @author Citizen Luther from TianYa BlackSmith's Shop
  6. // @author Master Rhino from TianYa BlackSmith's Shop
  7. // @description 天涯社区楼层计数、过滤指定用户的回贴。
  8. // @include http://bbs.tianya.cn/*
  9. // @exclude
  10. // @grant GM_getValue
  11. // @grant GM_setValue
  12. // @grant GM_getResourceText
  13. // @grant GM_addStyle
  14. // @require http://libs.baidu.com/jquery/1.9.1/jquery.min.js
  15. // @require http://libs.baidu.com/jqueryui/1.10.2/jquery-ui.min.js
  16. // @resource jqCSS https://libs.baidu.com/jqueryui/1.10.4/css/jquery-ui.min.css
  17. // @copyright 2013+, Citizen Luther
  18. // Released under the GPL license
  19. // http://www.gnu.org/copyleft/gpl.html
  20. // Appreciate to
  21. // Tianya Helper (http://userscripts.org/scripts/show/127574)
  22. // script link: http://userscripts.org/scripts/show/169619
  23. // ver 0.1 @ 2013-6-4
  24. // Initialize release
  25. // ver 0.2 @ 2013-6-4
  26. // + 增加选项,可设置过滤模式
  27. // * 做了一些优化
  28. // ver 1.0 @ 2013-6-6
  29. // + 增加关注某人功能,关注ID的回贴,设置背景色为环保绿色
  30. // + 增加数楼层、黑名单屏蔽效果的设置项
  31. // * 修正因大小写不符导致屏蔽失败的问题
  32. // ver 1.0.1 @ 2013-6-9
  33. // * 修正用户名中含有特殊字符或英文字符在前导致无法过滤的问题
  34. // ver 1.1.0 @ 2013-6-16
  35. // + 增加鼠标跟随的快捷链接:拉黑、洗白、关注、取关,用于快捷维护黑白名单
  36. // ver 1.1.1 @ 2013-6-19
  37. // + 增加“高亮提到我的”选项,默认关闭
  38. // ver 1.2.0 @ 2013-8-14
  39. // * 修复因天涯升级导致的举报及回复功能失效问题
  40. // ver 1.2.1 @ 2014-5-29
  41. // * 修复在重新打开浏览器时重复数楼层问题
  42. // ver 1.2.2 @ 2014-7-4
  43. // * 修复因天涯改版导致的菜单失效问题
  44. // ver 1.2.3 @ 2016-7-1
  45. // + 增加小广告一键举报、过滤功能
  46. // ver 1.2.4 @ 2016-7-4
  47. // * 修复同一页面同一小广告ID发贴不能过滤问题
  48. // ==/UserScript==
  49.  
  50. /*-----------------------------------------------------------------------------
  51. * Declaration
  52. *-------------------------------------------------------------------------- */
  53. HIGHLIGHT_COLOR = "#CCE8CF"; //环保背景色
  54.  
  55. var TianyaConfig = function () {
  56. this.blackList = ','; //黑名单
  57. this.adBlackList = ','; //广告黑名单
  58. this.whiteList = ','; //白名单
  59. this.filterMode = 1; //过滤模式:0-过滤回帖和用户信息;1-过滤回帖,不过滤用户信息
  60. this.floorNum = 1; //数楼层开关:0-关,1-开
  61. this.focusReplyMe = 0; //是否高亮提到我的回帖:0-否,1-是
  62. this.init();
  63. };
  64.  
  65. //日期格式化输出
  66. Date.prototype.Format = function (fmt) {
  67. var o = {
  68. "M+": this.getMonth() + 1, //月份
  69. "d+": this.getDate(), //日
  70. "h+": this.getHours(), //小时
  71. "m+": this.getMinutes(), //分
  72. "s+": this.getSeconds(), //秒
  73. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  74. "S": this.getMilliseconds() //毫秒
  75. };
  76. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  77. for (var k in o)
  78. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  79. return fmt;
  80. };
  81.  
  82. /* config format: key:writer0,writer1..:status ... */
  83. TianyaConfig.prototype = {
  84. saveBlackIDs: function () {
  85. GM_setValue('TianYaBlackIDs', this.blackList);
  86. },
  87. __getBlackIDs: function () {
  88. var escBlackIds = GM_getValue('TianYaBlackIDs');
  89. if (typeof escBlackIds !== "undefined" && escBlackIds !== '') {
  90. this.blackList = escBlackIds;
  91. }
  92. },
  93. saveAdBlackIDs: function () {
  94. GM_setValue('TianYaAdBlackIDs', this.adBlackList);
  95. },
  96. __getAdBlackIDs: function () {
  97. var escAdBlackIds = GM_getValue('TianYaAdBlackIDs');
  98. if (typeof escAdBlackIds !== "undefined" && escAdBlackIds !== '') {
  99. this.adBlackList = escAdBlackIds;
  100. //广告ID黑名单有效期一天,如非当天,清空黑名单
  101. var curDate = new Date().Format("yyyy-MM-dd");
  102. if (this.adBlackList.indexOf(curDate)!==0)
  103. this.adBlackList = curDate + ",";
  104. //alert("adBlackList=" + this.adBlackList);
  105. }
  106. },
  107. saveWhiteIDs: function () {
  108. GM_setValue('TianYaWhiteIDs', this.whiteList);
  109. },
  110. __getWhiteIDs: function () {
  111. var escWhiteIds = GM_getValue('TianYaWhiteIDs');
  112. if (typeof escWhiteIds !== "undefined" && escWhiteIds !== '') {
  113. this.whiteList = escWhiteIds;
  114. }
  115. },
  116. saveOptions: function () {
  117. GM_setValue('TianYaFilterMode', this.filterMode);
  118. GM_setValue('TianYaFloorNum', this.floorNum);
  119. GM_setValue('TianYaFocusReplyMe', this.focusReplyMe);
  120. },
  121. __getOptions: function () {
  122. var escFilterMode = GM_getValue('TianYaFilterMode');
  123. var escFloorNum = GM_getValue('TianYaFloorNum');
  124. var escFocusReplyMe = GM_getValue('TianYaFocusReplyMe');
  125.  
  126. if (typeof escFilterMode != "undefined") this.filterMode = escFilterMode;
  127. if (typeof escFloorNum != "undefined") this.floorNum = escFloorNum;
  128. if (typeof escFocusReplyMe != "undefined") this.focusReplyMe = escFocusReplyMe;
  129. },
  130. init: function () {
  131. this.__getBlackIDs();
  132. this.__getAdBlackIDs();
  133. this.__getWhiteIDs();
  134. this.__getOptions();
  135. }
  136. };
  137.  
  138. /*-----------------------------------------------------------------------------
  139. * Initialization
  140. *-------------------------------------------------------------------------- */
  141. if (typeof Tyconfig == 'undefined') {
  142. Tyconfig = new TianyaConfig();
  143. }
  144.  
  145. var eleHeader = document.getElementsByClassName("read-menu")[0];
  146. if (typeof eleHeader != 'undefined' && $("#tianya_helpbar").size() === 0) {
  147. var btnBlack = document.createElement("a");
  148. btnBlack.id = "btn_filter";
  149. btnBlack.className = "ty_filter";
  150. btnBlack.href = 'javascript:void(0)';
  151. btnBlack.textContent = "设置天涯过滤器";
  152. eleHeader.appendChild(btnBlack);
  153.  
  154. var jqCSS = GM_getResourceText("jqCSS");
  155. GM_addStyle(jqCSS);
  156.  
  157. var helpbar = document.createElement('div');
  158. helpbar.id = "tianya_helpbar";
  159. helpbar.align = "center";
  160. helpbar.style.display = "none";
  161. helpbar.innerHTML =
  162. '<div id="tabs" style="width:100%" align="left">\
  163. <ul>\
  164. <li><a href="#tabs-1">黑名单</a></li>\
  165. <li><a href="#tabs-2">白名单</a></li>\
  166. <li><a href="#tabs-3">设置</a></li>\
  167. </ul>\
  168. <div id="tabs-1">\
  169. <span>输入需要屏蔽的天涯ID,用逗号分隔,不要有空格:</span><br/>\
  170. <textarea title="提交后,新增ID会被屏蔽,但从黑名单删除的ID的回贴不会出现,需要F5。" id="txt_black_list" \
  171. class="tyblackid" rows="5" cols="40" wrap="virtual">\
  172. </textarea><br/>\
  173. <button id="btn_submit_black" class="btn_submit">提交</button>\
  174. <button class="btn_cancel">关闭</button>\
  175. </div>\
  176. <div id="tabs-2">\
  177. <span>输入需要关注的天涯ID,用逗号分隔:</span><br/>\
  178. <textarea title="白名单ID的回贴,将以环保绿色背景标记。" id="txt_white_list" \
  179. class="tywhiteid" rows="5" cols="40" wrap="virtual">\
  180. </textarea><br/>\
  181. <button id="btn_submit_white" class="btn_submit">提交</button>\
  182. <button class="btn_cancel">关闭</button>\
  183. </div>\
  184. <div id="tabs-3">\
  185. <span>修改选项保存后,需要刷新页面才在当前页生效。</span><br/><br/>\
  186. <input id="chk_floor" type="checkbox" title="打勾后将显示天涯楼层"> 页内数楼层</input><br/> \
  187. <input id="chk_filter_mode" type="checkbox" title="黑名单过滤模式,未选则连ID信息一起过滤"> 只过滤回贴内容,保留用户信息</input><br/>\
  188. <input id="chk_focus_me" type="checkbox" title="以粗体标记提到我的回帖"> 高亮提到我的回复(登录(不可用)后生效)</input><br/>\
  189. <br/><br/>\
  190. <button id="btn_submit_option" class="btn_submit">保存</button>\
  191. <button class="btn_cancel">关闭</button>\
  192. </div>\
  193. </div>';
  194. eleHeader.appendChild(helpbar);
  195.  
  196. GM_addStyle(".btn_submit { padding-top:5px;padding-right:10px;padding-bottom:5px;padding-left:10px; }");
  197. GM_addStyle(".btn_cancel { padding-top:5px;padding-right:10px;padding-bottom:5px;padding-left:10px; }");
  198.  
  199. // Tab switch
  200. $(function() {
  201. $("#tabs").tabs();
  202. });
  203.  
  204. // Show and initialize Tianya Filter configuration view
  205. $("#btn_filter").click(function(){
  206. document.getElementById("tianya_helpbar").style.display = "block";
  207. $("#tabs").tabs("option", "active", 0);
  208.  
  209. document.getElementById("txt_black_list").value = Tyconfig.blackList.substring(1,Tyconfig.blackList.length-1);
  210. document.getElementById("txt_white_list").value = Tyconfig.whiteList.substring(1,Tyconfig.whiteList.length-1);
  211. document.getElementById("chk_filter_mode").checked = Tyconfig.filterMode==1?true:false;
  212. document.getElementById("chk_floor").checked = Tyconfig.floorNum==1?true:false;
  213. document.getElementById("chk_focus_me").checked = Tyconfig.focusReplyMe==1?true:false;
  214. });
  215.  
  216. $("#btn_submit_option").click(function(){
  217. var opt_mode = document.getElementById("chk_filter_mode").checked?1:0;
  218. var opt_floor = document.getElementById("chk_floor").checked?1:0;
  219. var opt_focus = document.getElementById("chk_focus_me").checked?1:0;
  220.  
  221. if (Tyconfig.filterMode != opt_mode || Tyconfig.floorNum != opt_floor || Tyconfig.focusReplyMe != opt_focus) {
  222. Tyconfig.filterMode = opt_mode;
  223. Tyconfig.floorNum = opt_floor;
  224. Tyconfig.focusReplyMe = opt_focus;
  225. Tyconfig.saveOptions();
  226. }
  227. document.getElementById("tianya_helpbar").style.display = "none";
  228. });
  229.  
  230. document.getElementById("btn_submit_black").onclick=function(event){
  231. submitList(event);
  232. };
  233.  
  234. document.getElementById("btn_submit_white").onclick=function(event){
  235. submitList(event);
  236. };
  237.  
  238. // Submit the change of black list or white list.
  239. function submitList(event) {
  240. var target = event.currentTarget;
  241. var idList = "";
  242.  
  243. if (target.id == "btn_submit_black")
  244. idList = document.getElementById("txt_black_list").value;
  245. else if (target.id == "btn_submit_white")
  246. idList = document.getElementById("txt_white_list").value;
  247.  
  248. while (idList.length > 0 && idList.indexOf(",") > -1) {
  249. idList = idList.replace(",",",");
  250. }
  251. if (idList.indexOf(",") > 0 || idList.indexOf(",") == -1) idList = "," + idList;
  252. if (idList.substring(idList.length - 1, idList.length) != ",") idList = idList + ",";
  253. idList = idList.toLowerCase();
  254.  
  255. if (target.id == "btn_submit_black") {
  256. Tyconfig.blackList = idList;
  257. Tyconfig.saveBlackIDs();
  258. } else if (target.id == "btn_submit_white") {
  259. Tyconfig.whiteList = idList;
  260. Tyconfig.saveWhiteIDs();
  261. }
  262.  
  263. document.getElementById("tianya_helpbar").style.display = "none";
  264. // Filter again after list updated.
  265. filterPosts();
  266. }
  267.  
  268. $(".btn_cancel").click(function(){
  269. document.getElementById("tianya_helpbar").style.display = "none";
  270. });
  271. }
  272.  
  273.  
  274. /*-----------------------------------------------------------------------------
  275. * Main Program
  276. *-------------------------------------------------------------------------- */
  277. // 此结构中的function,在页面加载完毕才会执行,确保不出错。
  278. $(document).ready(function(){
  279.  
  280. addMenuAndCountFloor();
  281.  
  282. filterPosts();
  283.  
  284. // 高亮提到自己的回复,需要登录(不可用)后才能使用
  285. if (Tyconfig.focusReplyMe == 1) {
  286. var myid = $("a[appstr='mypage']").text();
  287. if (typeof myid !== "undefined" && myid !== "")
  288. $(".bbs-content:contains('" + myid + "')").css("font-weight", "bold");
  289. }
  290.  
  291. $(".tyf_link").click(function() {
  292. var ftype = $(this).attr("tyf_type");
  293. var author = $(this).parent().find(".js-vip-check").attr("uname").toLowerCase();
  294. var pos = -1;
  295.  
  296. switch (ftype) {
  297. case "1": //拉黑,加入黑名单
  298. if (Tyconfig.blackList.indexOf(","+author+",") < 0) {
  299. Tyconfig.blackList += author + ",";
  300. Tyconfig.saveBlackIDs();
  301.  
  302. $(this).hide();
  303. $(this).parent().find(".tyf_link[tyf_type=2]").show();
  304. $(this).parent().find(".tyf_link[tyf_type=3]").hide();
  305. }
  306. break;
  307. case "2": //洗白,从黑名单中删除
  308. pos = Tyconfig.blackList.indexOf(","+author+",");
  309. if ( pos >= 0) {
  310. Tyconfig.blackList = Tyconfig.blackList.substr(0,pos) + Tyconfig.blackList.substr(pos + author.length + 1);
  311. Tyconfig.saveBlackIDs();
  312.  
  313. $(this).hide();
  314. $(this).parent().find(".tyf_link[tyf_type=1]").show();
  315. $(this).parent().find(".tyf_link[tyf_type=3]").show();
  316. }
  317. break;
  318. case "3": //关注,加入白名单
  319. if (Tyconfig.whiteList.indexOf(","+author+",") < 0) {
  320. Tyconfig.whiteList += author + ",";
  321. Tyconfig.saveWhiteIDs();
  322.  
  323. $(this).hide();
  324. $(this).parent().find(".tyf_link[tyf_type=1]").hide();
  325. $(this).parent().find(".tyf_link[tyf_type=4]").show();
  326. }
  327. break;
  328. case "4": //取关,从白名单中删除
  329. pos = Tyconfig.whiteList.indexOf(","+author+",");
  330. if ( pos >= 0) {
  331. Tyconfig.whiteList = Tyconfig.whiteList.substr(0,pos) + Tyconfig.whiteList.substr(pos + author.length + 1);
  332. Tyconfig.saveWhiteIDs();
  333.  
  334. $(this).hide();
  335. $(this).parent().find(".tyf_link[tyf_type=1]").show();
  336. $(this).parent().find(".tyf_link[tyf_type=3]").show();
  337. }
  338. break;
  339. case "6": //显示,取消隐藏
  340. $(this).parent().parent().parent().find("div.atl-content").first().show();
  341. pos = Tyconfig.adBlackList.indexOf(","+author+",");
  342. if ( pos >= 0) {
  343. Tyconfig.adBlackList = Tyconfig.adBlackList.substr(0,pos) + Tyconfig.adBlackList.substr(pos + author.length + 1);
  344. Tyconfig.saveAdBlackIDs();
  345. }
  346.  
  347. $(this).hide();
  348. $(this).parent().find("a.reportme.a-link[tyf_type=5]").show();
  349. break;
  350. }
  351. filterPosts(ftype, $(this).parent().parent().parent().attr("js_username"));
  352. });
  353.  
  354. //广告ID举报后直接隐藏,并把ID加入广告ID黑名单
  355. $("a.reportme.a-link[tyf_type=5]").click(function() {
  356. //$(this).parent().parent().parent().find("div.atl-content").first().hide();
  357. Tyconfig.adBlackList += $(this).attr("author") + ",";
  358. Tyconfig.saveAdBlackIDs();
  359. //alert("adBlackList=" + Tyconfig.adBlackList);
  360. $(".atl-item[js_username='" + $(this).parent().parent().parent().attr("js_username") + "']").find(".atl-content").hide();
  361.  
  362. $(this).hide();
  363. $(this).parent().find(".tyf_link[tyf_type=6]").show();
  364. });
  365. });
  366.  
  367. /*-----------------------------------------------------------------------------
  368. * Functions
  369. *-------------------------------------------------------------------------- */
  370.  
  371. // For every user header, add menu for TianyaFilter, and count the floor number
  372. function addMenuAndCountFloor() {
  373. var eHeads = document.getElementsByClassName("atl-info");
  374. var rpts = $("a.reportme.a-link");
  375. if ($("a.bbs-layer").size() > 0) Tyconfig.floorNum = 0;
  376. if ($(".floornum").size() > 0) Tyconfig.floorNum = 0;
  377.  
  378. for (var i=1; i<eHeads.length; i++){
  379. var ele = eHeads[i];
  380. //var rply = ele.parentNode.parentNode.find(".atl-reply");
  381. //var rpt = $("div.atl-reply:eq(" + i + ")").find(".reportme").first();
  382. var rpt = rpts[i-1];
  383.  
  384. ele.innerHTML = ele.innerHTML +
  385. "<a class='tyf_link' tyf_type='1' href='javascript:void(0)'>拉黑</a> " +
  386. "<a class='tyf_link' tyf_type='2' href='javascript:void(0)'>洗白</a> " +
  387. "<a class='tyf_link' tyf_type='3' href='javascript:void(0)'>关注</a> " +
  388. "<a class='tyf_link' tyf_type='4' href='javascript:void(0)'>取关</a> " +
  389. "<a class='reportme a-link' tyf_type='5' href='javascript:void(0)' replyid=" + rpt.getAttribute("replyid") + " replytime=" + rpt.getAttribute("replytime") +
  390. " author=" + rpt.getAttribute("author") + " authorid=" + rpt.getAttribute("authorid") + ">举报</a>" +
  391. "<a class='tyf_link' tyf_type='6' href='javascript:void(0)'>显示</a> ";
  392. if (Tyconfig.floorNum == 1 && i>0)
  393. ele.innerHTML = "<span class='floornum'>" + i + "楼</span>" + ele.innerHTML;
  394. }
  395.  
  396. GM_addStyle(".tyf_link { color:blue } ");
  397. GM_addStyle("a.reportme.a-link { color:red } ");
  398. $(".tyf_link").hide();
  399. $("a.reportme.a-link[tyf_type=5]").hide();
  400. }
  401.  
  402. // 鼠标跟随效果,黑名单ID显示“洗白”,白名单ID显示“取关”,其他ID显示“拉黑、关注”;非广告ID显示“举报”,广告ID显示“显示”
  403. $(".atl-item").hover(
  404. function () {
  405. var author = Utf8ToGb2312($(this).attr("js_username")).toLowerCase();
  406. if (Tyconfig.blackList.indexOf(","+author+",") >= 0)
  407. $(this).find(".tyf_link[tyf_type=2]").show();
  408. else if (Tyconfig.whiteList.indexOf(","+author+",") >= 0)
  409. $(this).find(".tyf_link[tyf_type=4]").show();
  410. else {
  411. $(this).find(".tyf_link[tyf_type=1]").show();
  412. $(this).find(".tyf_link[tyf_type=3]").show();
  413. }
  414. if (Tyconfig.adBlackList.indexOf(","+author+",") >= 0)
  415. $(this).find(".tyf_link[tyf_type=6]").show();
  416. else
  417. $(this).find("a.reportme.a-link[tyf_type=5]").show();
  418. },
  419. function () {
  420. $(this).find(".tyf_link").hide();
  421. $(this).find("a.reportme.a-link[tyf_type=5]").hide();
  422. }
  423. );
  424.  
  425.  
  426. // Filter posts of black IDs, and highlight posts of focused IDs.
  427. function filterPosts(ftype, fauthor) {
  428. if (typeof ftype != "undefined" && typeof fauthor != "undefined") {
  429. switch (ftype) {
  430. case "1":
  431. if (Tyconfig.filterMode == 1)
  432. $(".atl-item[js_username='" + fauthor + "']").find(".atl-content").hide();
  433. else
  434. $(".atl-item[js_username='" + fauthor + "']").hide();
  435. break;
  436. case "2":
  437. if (Tyconfig.filterMode == 1)
  438. $(".atl-item[js_username='" + fauthor + "']").find(".atl-content").show();
  439. else
  440. $(".atl-item[js_username='" + fauthor + "']").show();
  441. break;
  442. case "3":
  443. $(".atl-item[js_username='" + fauthor + "']").find(".atl-con-bd").css("background", HIGHLIGHT_COLOR);
  444. break;
  445. case "4":
  446. $(".atl-item[js_username='" + fauthor + "']").find(".atl-con-bd").css("background", "#EEE");
  447. break;
  448. }
  449. } else {
  450. var eItems = document.getElementsByClassName("atl-item");
  451. for (i=0; i<eItems.length; i++){
  452. var ele = eItems[i];
  453. var username = ele.getAttribute("js_username");
  454. if (username === null) continue;
  455.  
  456. var authorId = Utf8ToGb2312(username);
  457. authorId = authorId.toLowerCase();
  458.  
  459. if (Tyconfig.blackList.indexOf(","+authorId+",")>=0 || Tyconfig.adBlackList.indexOf(","+authorId+",")>=0){
  460. //屏蔽回贴模式,只隐藏回贴,否则将包含用户信息的整个div隐藏
  461. if (Tyconfig.filterMode == 1) {
  462. var post = ele.getElementsByClassName("atl-content")[0];
  463. post.style.display = "none";
  464. } else {
  465. ele.style.display = "none";
  466. }
  467. } else if (Tyconfig.whiteList.indexOf(","+authorId+",") >= 0){ //关注ID的回贴,设置背景色为环保绿色
  468. var cell = ele.getElementsByClassName("atl-con-bd clearfix")[0];
  469. cell.style.backgroundColor = HIGHLIGHT_COLOR;
  470. }
  471. }
  472. }
  473. }
  474.  
  475. // Decode chinese charactor from UTF8 to GB2312
  476. function Utf8ToGb2312(str1){
  477. var substr = "";
  478. var a = "";
  479. var b = "";
  480. var c = "";
  481. var i = -1;
  482. i = str1.indexOf("%");
  483. if(i==-1){
  484. return str1;
  485. }
  486. while(i!= -1){
  487. if(i<3){
  488. substr = substr + str1.substr(0,i);
  489. str1 = str1.substr(i+1,str1.length-i);
  490. a = str1.substr(0,2);
  491. str1 = str1.substr(2,str1.length - 2);
  492. if(parseInt("0x" + a) & 0x80 === 0){
  493. substr = substr + String.fromCharCode(parseInt("0x" + a));
  494. }
  495. else if(parseInt("0x" + a) & 0xE0 == 0xC0){ //two byte
  496. b = str1.substr(1,2);
  497. str1 = str1.substr(3,str1.length - 3);
  498. var widechar = (parseInt("0x" + a) & 0x1F) << 6;
  499. widechar = widechar | (parseInt("0x" + b) & 0x3F);
  500. substr = substr + String.fromCharCode(widechar);
  501. }
  502. else{
  503. b = str1.substr(1,2);
  504. str1 = str1.substr(3,str1.length - 3);
  505. c = str1.substr(1,2);
  506. str1 = str1.substr(3,str1.length - 3);
  507. var widechar = (parseInt("0x" + a) & 0x0F) << 12;
  508. widechar = widechar | ((parseInt("0x" + b) & 0x3F) << 6);
  509. widechar = widechar | (parseInt("0x" + c) & 0x3F);
  510. substr = substr + String.fromCharCode(widechar);
  511. }
  512. }
  513. else {
  514. substr = substr + str1.substring(0,i);
  515. str1= str1.substring(i);
  516. }
  517. i = str1.indexOf("%");
  518. }
  519.  
  520. return substr+str1;
  521. }

QingJ © 2025

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