|
3 | 3 | // @name:zh-CN 代码片段高亮 |
4 | 4 | // @name:zh-TW 程式碼片斷高亮 |
5 | 5 | // @namespace hoothin |
6 | | -// @version 2.2.3 |
| 6 | +// @version 2.2.3.1 |
7 | 7 | // @description Add a icon to popup a window that allows syntax highlighting and beautify and word count of source code snippets on current page |
8 | 8 | // @description:zh-CN 选择代码片段后点击图标弹出新窗口显示语法高亮美化与格式化后的代码与字数统计 |
9 | 9 | // @description:zh-TW 選擇程式碼片段後點選圖示彈出新視窗顯示語法高亮美化與格式化後的程式碼與字數統計 |
|
122 | 122 | codes=selStr.replace(/&/g, "&").replace(/\</g,"<").replace(/\>/g,">"); |
123 | 123 | } |
124 | 124 | let html='<title>Code Snippet</title>'+ |
125 | | - '<link rel="stylesheet" href="https://cdn.rawgit.com/google/code-prettify/master/styles/sons-of-obsidian.css"/>'+ |
126 | | - '<script>var code,codeStr;window.onload=function(){code=document.querySelector("#code");codeStr=code.innerHTML.replace(/&/g, "&").replace(/&(nbsp;|amp;|#39;|quot;)/g, "&$1");prettyPrint();'+ |
127 | | - 'document.querySelector("body>a:nth-child(1)").onclick=function(){'+ |
| 125 | + '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css"/>'+ |
| 126 | + '<script>var code,codeStr;window.onload=function(){code=document.querySelector("#code");codeStr=code.innerHTML.replace(/ /g, " ").replace(/&/g, "&").replace(/&(nbsp;|amp;|#39;|quot;)/g, "&$1");prettyPrint();'+ |
| 127 | + 'document.querySelector("#js").onclick=function(){'+ |
128 | 128 | 'code.innerHTML=js_beautify('+ |
129 | 129 | 'codeStr.replace(/>/g, \'>\').replace(/</g, \'<\').replace(/\'(\\\\\'|[^\'])*?\'/g, function(word){'+ |
130 | 130 | 'return word.replace(/>/g, \'>\').replace(/</g, \'<\');}'+ |
|
136 | 136 | '<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.6.4/beautify.min.js"></script>'+ |
137 | 137 | '<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.6.4/beautify-html.min.js"></script>'+ |
138 | 138 | '<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.6.4/beautify-css.min.js"></script>'+ |
139 | | - 'Code formatting: <a href="#">Javaspcript</a> '+ |
| 139 | + 'Code formatting: <a id="js" href="#">Javaspcript</a> '+ |
140 | 140 | '<a href="#" onclick="code.innerHTML=html_beautify(codeStr);code.className=\'prettyprint linenums\';prettyPrint();return false;">Html</a> '+ |
141 | 141 | '<a href="#" onclick="code.innerHTML=css_beautify(codeStr);code.className=\'prettyprint linenums\';prettyPrint();return false;">Css</a> '+ |
142 | 142 | '<a href="#" onclick="code.innerHTML=codeStr;code.className=\'prettyprint linenums\';prettyPrint();return false;">Raw</a> <b style="color:red">('+selStr.replace(/\s/g,"").length+' words)</b>'+ |
|
0 commit comments