WordPress 使用 Google Code Prettify 高亮代码

Google Code Prettify 是 Google 开源的一个用于代码高亮的 Javascript 库,支持 C/C++, Java, Python, Ruby, PHP,Javascript 等等常见语言,目前包括 Google Code、Stackoverflow.com 在内的很多网站都在使用它。最吸引人的是,在使用它进行代码高亮时,甚至不需要指明语言类型,Prettify 会自动判断并处理。

google-code-prettify-javascript-syntax-highlighter

使用 Prettify 一般只需要包含两个文件:prettify.js 和 prettify.css,压缩过后的 prettify.js 大小差不多在 15K 左右,非常小巧。

简单使用

在网站页面中引用 Prettify文件:

<link href="prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="prettify.js"></script>

同时增加以下代码,让页面加载完成时执行 Prettify:

<script type="text/javascript">
window.onload = function(){prettyPrint();};
</script>

Prettify 会在网页中查找<pre class="prettyprint">...</pre>或者<code class="prettyprint">...</code>包围的代码片断,对它们进行高亮。

查看全文

Remove Google Redirection 扩展

Remove Google Redirection 扩展修改自之前的 Greasemonkey脚本,两者的功能是一样的,只不过扩展的优点是可以利用 Google 同步功能在不同的电脑上实时同步,避免重新安装 Chrome 或者换电脑的时候还要手动人肉安装脚本,目前已经支持的浏览器包括 Safari 和 Chrome,Firefox 可以继续使用 Greasemonkey 脚本。

简介

这个扩展的功能其实不需要太多介绍,常用谷歌的人都了解,Google会在搜索链接结果中加上重定向的功能,点击搜索结果中的任意链接,Google都会带着你转一圈。在点击链接的瞬间,观察你的地址栏,此时你会发现地址栏的链接不是原始的链接,而是经过google.com转换后的链接地址,一会儿后才会跳转到实际链接。而此时,由于国情,你很有可能非常不幸地被重置了。

查看全文

Remove Google Redirection

This user script has been published on UserScripts.org for near one year, which is made to prohibit click-tracking and prevent redirection in the Google search results. I'm very surprised by so many downloads in UserScripts.org, about 6,805 times. I think many people really need this function provided by this script. So I have decided to update it since last update about three months ago.

What and Why

You can read this blog “Block Google from Click Tracking Web Search Results” for more information about "what is click-tracking and how it track user click event".

Sometimes click-tracking and URL redirection are very annoying, especially when Google is not well accessible for some reason. In this case, we need a method to remove this, so we can directly visit the original site URL rather than indirectly through Google.

Support and Feedback

Because of some technical reasons, the previous versions didn't support very well when Instant Search is on. And the Google search URLs were not listed completely in the @include metablock of UserScript. Now this script support both instant on and instant off search, and I added the missing URLs in the @include. You can add your favorite Google search URLs as you like.

查看全文