加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 喵呜喵5 于 2015-1-28 22:12 编辑
Bookmarklet三连发…………
javascript:(function(){ var code,list,i,j,log,temp; list = []; temp = document.getElementsByTagName('div'); for (i = 0; i < temp.length; i++) { list.push(temp[i]); } temp = document.getElementsByTagName('pre'); for (i = 0; i < temp.length; i++) { list.push(temp[i]); } for (i = 0; i < list.length; i++) { if(list[i].className != "blockcode" ){ continue } code = list[i].getElementsByTagName('li'); for (j = 0; j < code.length; j++) { if (list[i].tagName == "PRE"){ while( /(.*)<span.*>(.*)<\/span>(.*)/.test(code[j].innerHTML) ){ code[j].innerHTML = RegExp.$1+RegExp.$2+RegExp.$3; } } if( /(.*)\[url=.*\]@(.*)\[\/url\](.*)/.test(code[j].innerHTML) ){ log = "脚本的第" + (j + 1) + "行从 " + code[j].innerHTML + " 修改成了 "; while( /(.*)\[url=.*\]@(.*)\[\/url\](.*)/.test(code[j].innerHTML) ){ code[j].innerHTML = RegExp.$1+"@"+RegExp.$2.toLocaleLowerCase()+RegExp.$3; } log += code[j].innerHTML; list[i].innerHTML += '<br>' + log.replace(/<br>/g," "); } } }})()
javascript:(function(){ var code,list,i,j,log,temp; list = []; temp = document.getElementsByTagName('div'); for (i = 0; i < temp.length; i++) { list.push(temp[i]); } temp = document.getElementsByTagName('pre'); for (i = 0; i < temp.length; i++) { list.push(temp[i]); } for (i = 0; i < list.length; i++) { if(list[i].className != "blockcode" ){ continue } code = list[i].getElementsByTagName('li'); for (j = 0; j < code.length; j++) { if (list[i].tagName == "PRE"){ while( /(.*)<span.*>(.*)<\/span>(.*)/.test(code[j].innerHTML) ){ code[j].innerHTML = RegExp.$1+RegExp.$2+RegExp.$3; } } if( /(.*)\[url=.*\]@(.*)\[\/url\](.*)/.test(code[j].innerHTML) ){ log = "脚本的第" + (j + 1) + "行从 " + code[j].innerHTML + " 修改成了 "; while( /(.*)\[url=.*\]@(.*)\[\/url\](.*)/.test(code[j].innerHTML) ){ code[j].innerHTML = RegExp.$1+"@"+RegExp.$2.toLocaleLowerCase()+RegExp.$3; } log += code[j].innerHTML; list[i].innerHTML += '<br>' + log.replace(/<br>/g," "); } } }})()
Bookmarklet的使用方法看这里:https://rpg.blue/thread-375696-1-1.html
在包含代码框的页面点一下这个书签就会自动进行修正并在代码框底部列出修正结果
彩色代码框的修正还存在以下问题:
- 代码框的高亮会失效
- 代码右上角的复制无法使用,需要手动全选后复制
- 修改记录会发生诡异的换行
目前还在测试中,如果哪个代码框解析错误或者无法解析请回复告诉我
附带测试数据:- [url=home.php?mod=space&uid=102614]@taroxd[/url] = 233
复制代码- [url=home.php?mod=space&uid=336539]@VIPArcher[/url] = [url=home.php?mod=space&uid=32466]@Index[/url]
复制代码- [url=home.php?mod=space&uid=32466]@Index[/url] = 456
- [url=home.php?mod=space&uid=32466]@Index[/url] = 789
复制代码[url=home.php?mod=space&uid=102614]@taroxd[/url] = 233
[url=home.php?mod=space&uid=102614]@taroxd[/url] = 233
[url=home.php?mod=space&uid=336539]@VIPArcher[/url] = [url=home.php?mod=space&uid=32466]@Index[/url]
[url=home.php?mod=space&uid=336539]@VIPArcher[/url] = [url=home.php?mod=space&uid=32466]@Index[/url]
[url=home.php?mod=space&uid=32466]@Index[/url] = 456 [url=home.php?mod=space&uid=32466]@Index[/url] = 789
[url=home.php?mod=space&uid=32466]@Index[/url] = 456
[url=home.php?mod=space&uid=32466]@Index[/url] = 789
|