Snipplr纯文本/高亮文本Greasemonkey脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Snipplr纯文本/高亮文本Greasemonkey脚本相关的知识,希望对你有一定的参考价值。

When you're viewing an older version of a snippet, the Plain Text and Highlighted Text links point back to the latest version. This greasemonkey script fixes those links to point to the version you're currently viewing.
  1. // ==UserScript==
  2. // @name Fix Snippet's Plain/Highlighted Text link
  3. // @author Andy Harrison
  4. // @namespace http://dragonzreef.com/greasemonkey/snipplr_plainhighlighted.user.js
  5. // @description When viewing a snippet, fixes the Plain/Highligted Text link to go to the version you're looking at instead of the latest version.
  6. // @include http://snipplr.com/view*
  7. // ==/UserScript==
  8.  
  9. window.addEventListener("load", function()
  10. {
  11. var viewbar = document.getElementById("viewsource");
  12. if(!viewbar) return;
  13. var a = viewbar.getElementsByTagName("a");
  14. for(var i=0; i<a.length; i++)
  15. {
  16. if(a[i].innerhtml == "Plain Text")
  17. {
  18. a[i].href += document.location.href.replace(/^http://snipplr.com/view/d+(.d+).*$|.*/,"$1");
  19. return;
  20. }
  21. else if(a[i].innerHTML == "Highlighted Text")
  22. {
  23. var vers = document.location.href.replace(/^http://snipplr.com/view.php?([^#]*&)*?id=d+(.d+).*$|.*/,"$2");
  24. a[i].href = a[i].href.replace(/^(http://snipplr.com/view/d+)(.*)$/, "$1"+vers+"$2");
  25. return;
  26. }
  27. }
  28. }, false);

以上是关于Snipplr纯文本/高亮文本Greasemonkey脚本的主要内容,如果未能解决你的问题,请参考以下文章

简单文本格式管理器AS3

大段文本的多个关键字高亮

Notepad++文本编辑器

vscode小程序代码高亮

搜索文本后去掉 Vim 的高亮

CSS 文本高亮