├── answerSearch └── main.js ├── background.js ├── chatOnline ├── Markdown.Converter.js ├── SaeChannel.js ├── at.js ├── chatroom.css ├── desert.css ├── emotion.js ├── jquery-2.0.3.min.js ├── main.js └── prettify.js ├── cmt-enhanced ├── cmt-enhanced.css └── main.js ├── favicon.ico ├── hotkey └── main.js ├── img ├── icon128.png ├── icon16.png ├── icon24.png └── icon48.png ├── jquery-2.0.3.min.js ├── main.js ├── manifest.json ├── options.html ├── options.js ├── popup.html ├── readme.md └── reputation-chart-3d ├── iso.js ├── main.js └── obelisk.js /answerSearch/main.js: -------------------------------------------------------------------------------- 1 | chrome.storage.sync.get('answerSearch', function(d) { 2 | if(+d.answerSearch) return false; 3 | if(location.pathname.split('/').pop() != "answers") return false; 4 | 5 | var _t = $("h2.h4"); 6 | _t.after('
s around 276 | // "paragraphs" that are wrapped in non-block-level tags, such as anchors, 277 | // phrase emphasis, and spans. The list of tags we're looking for is 278 | // hard-coded: 279 | var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del" 280 | var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math" 281 | 282 | // First, look for nested blocks, e.g.: 283 | //
tags around block-level tags.
435 | text = _HashHTMLBlocks(text);
436 | text = _FormParagraphs(text, doNotUnhash);
437 |
438 | return text;
439 | }
440 |
441 | function _RunSpanGamut(text) {
442 | //
443 | // These are all the transformations that occur *within* block-level
444 | // tags like paragraphs, headers, and list items.
445 | //
446 |
447 | text = pluginHooks.preSpanGamut(text);
448 |
449 | text = _DoCodeSpans(text);
450 | text = _EscapeSpecialCharsWithinTagAttributes(text);
451 | text = _EncodeBackslashEscapes(text);
452 |
453 | // Process anchor and image tags. Images must come first,
454 | // because ![foo][f] looks like an anchor.
455 | text = _DoImages(text);
456 | text = _DoAnchors(text);
457 |
458 | // Make links out of things like ` Just type tags
1152 | //
1153 |
1154 | // Strip leading and trailing lines:
1155 | text = text.replace(/^\n+/g, "");
1156 | text = text.replace(/\n+$/g, "");
1157 |
1158 | var grafs = text.split(/\n{2,}/g);
1159 | var grafsOut = [];
1160 |
1161 | var markerRe = /~K(\d+)K/;
1162 |
1163 | //
1164 | // Wrap tags.
1165 | //
1166 | var end = grafs.length;
1167 | for (var i = 0; i < end; i++) {
1168 | var str = grafs[i];
1169 |
1170 | // if this is an HTML marker, copy it
1171 | if (markerRe.test(str)) {
1172 | grafsOut.push(str);
1173 | }
1174 | else if (/\S/.test(str)) {
1175 | str = _RunSpanGamut(str);
1176 | str = str.replace(/^([ \t]*)/g, " ");
1177 | str += "
\n");
470 |
471 | text = pluginHooks.postSpanGamut(text);
472 |
473 | return text;
474 | }
475 |
476 | function _EscapeSpecialCharsWithinTagAttributes(text) {
477 | //
478 | // Within tags -- meaning between < and > -- encode [\ ` * _] so they
479 | // don't conflict with their use in Markdown for code, italics and strong.
480 | //
481 |
482 | // Build a regex to find HTML tags and comments. See Friedl's
483 | // "Mastering Regular Expressions", 2nd Ed., pp. 200-201.
484 |
485 | // SE: changed the comment part of the regex
486 |
487 | var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|-]|-[^>])(?:[^-]|-[^-])*)--)>)/gi;
488 |
489 | text = text.replace(regex, function (wholeMatch) {
490 | var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g, "$1`");
491 | tag = escapeCharacters(tag, wholeMatch.charAt(1) == "!" ? "\\`*_/" : "\\`*_"); // also escape slashes in comments to prevent autolinking there -- http://meta.stackoverflow.com/questions/95987
492 | return tag;
493 | });
494 |
495 | return text;
496 | }
497 |
498 | function _DoAnchors(text) {
499 | //
500 | // Turn Markdown link shortcuts into XHTML tags.
501 | //
502 | //
503 | // First, handle reference-style links: [link text] [id]
504 | //
505 |
506 | /*
507 | text = text.replace(/
508 | ( // wrap whole match in $1
509 | \[
510 | (
511 | (?:
512 | \[[^\]]*\] // allow brackets nested one level
513 | |
514 | [^\[] // or anything else
515 | )*
516 | )
517 | \]
518 |
519 | [ ]? // one optional space
520 | (?:\n[ ]*)? // one optional newline followed by spaces
521 |
522 | \[
523 | (.*?) // id = $3
524 | \]
525 | )
526 | ()()()() // pad remaining backreferences
527 | /g, writeAnchorTag);
528 | */
529 | text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g, writeAnchorTag);
530 |
531 | //
532 | // Next, inline-style links: [link text](url "optional title")
533 | //
534 |
535 | /*
536 | text = text.replace(/
537 | ( // wrap whole match in $1
538 | \[
539 | (
540 | (?:
541 | \[[^\]]*\] // allow brackets nested one level
542 | |
543 | [^\[\]] // or anything else
544 | )*
545 | )
546 | \]
547 | \( // literal paren
548 | [ \t]*
549 | () // no id, so leave $3 empty
550 | ( // href = $4
551 | (?:
552 | \([^)]*\) // allow one level of (correctly nested) parens (think MSDN)
553 | |
554 | [^()\s]
555 | )*?
556 | )>?
557 | [ \t]*
558 | ( // $5
559 | (['"]) // quote char = $6
560 | (.*?) // Title = $7
561 | \6 // matching quote
562 | [ \t]* // ignore any spaces/tabs between closing quote and )
563 | )? // title is optional
564 | \)
565 | )
566 | /g, writeAnchorTag);
567 | */
568 |
569 | text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()((?:\([^)]*\)|[^()\s])*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g, writeAnchorTag);
570 |
571 | //
572 | // Last, handle reference-style shortcuts: [link text]
573 | // These must come last in case you've also got [link test][1]
574 | // or [link test](/foo)
575 | //
576 |
577 | /*
578 | text = text.replace(/
579 | ( // wrap whole match in $1
580 | \[
581 | ([^\[\]]+) // link text = $2; can't contain '[' or ']'
582 | \]
583 | )
584 | ()()()()() // pad rest of backreferences
585 | /g, writeAnchorTag);
586 | */
587 | text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag);
588 |
589 | return text;
590 | }
591 |
592 | function writeAnchorTag(wholeMatch, m1, m2, m3, m4, m5, m6, m7) {
593 | if (m7 == undefined) m7 = "";
594 | var whole_match = m1;
595 | var link_text = m2.replace(/:\/\//g, "~P"); // to prevent auto-linking withing the link. will be converted back after the auto-linker runs
596 | var link_id = m3.toLowerCase();
597 | var url = m4;
598 | var title = m7;
599 |
600 | if (url == "") {
601 | if (link_id == "") {
602 | // lower-case and turn embedded newlines into spaces
603 | link_id = link_text.toLowerCase().replace(/ ?\n/g, " ");
604 | }
605 | url = "#" + link_id;
606 |
607 | if (g_urls.get(link_id) != undefined) {
608 | url = g_urls.get(link_id);
609 | if (g_titles.get(link_id) != undefined) {
610 | title = g_titles.get(link_id);
611 | }
612 | }
613 | else {
614 | if (whole_match.search(/\(\s*\)$/m) > -1) {
615 | // Special case for explicit empty url
616 | url = "";
617 | } else {
618 | return whole_match;
619 | }
620 | }
621 | }
622 | url = encodeProblemUrlChars(url);
623 | url = escapeCharacters(url, "*_");
624 | var result = "" + link_text + "";
633 |
634 | return result;
635 | }
636 |
637 | function _DoImages(text) {
638 | //
639 | // Turn Markdown image shortcuts into tags.
640 | //
641 |
642 | //
643 | // First, handle reference-style labeled images: ![alt text][id]
644 | //
645 |
646 | /*
647 | text = text.replace(/
648 | ( // wrap whole match in $1
649 | !\[
650 | (.*?) // alt text = $2
651 | \]
652 |
653 | [ ]? // one optional space
654 | (?:\n[ ]*)? // one optional newline followed by spaces
655 |
656 | \[
657 | (.*?) // id = $3
658 | \]
659 | )
660 | ()()()() // pad rest of backreferences
661 | /g, writeImageTag);
662 | */
663 | text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g, writeImageTag);
664 |
665 | //
666 | // Next, handle inline images: 
667 | // Don't forget: encode * and _
668 |
669 | /*
670 | text = text.replace(/
671 | ( // wrap whole match in $1
672 | !\[
673 | (.*?) // alt text = $2
674 | \]
675 | \s? // One optional whitespace character
676 | \( // literal paren
677 | [ \t]*
678 | () // no id, so leave $3 empty
679 | (\S+?)>? // src url = $4
680 | [ \t]*
681 | ( // $5
682 | (['"]) // quote char = $6
683 | (.*?) // title = $7
684 | \6 // matching quote
685 | [ \t]*
686 | )? // title is optional
687 | \)
688 | )
689 | /g, writeImageTag);
690 | */
691 | text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g, writeImageTag);
692 |
693 | return text;
694 | }
695 |
696 | function attributeEncode(text) {
697 | // unconditionally replace angle brackets here -- what ends up in an attribute (e.g. alt or title)
698 | // never makes sense to have verbatim HTML in it (and the sanitizer would totally break it)
699 | return text.replace(/>/g, ">").replace(/";
743 |
744 | return result;
745 | }
746 |
747 | function _DoHeaders(text) {
748 |
749 | // Setext-style headers:
750 | // Header 1
751 | // ========
752 | //
753 | // Header 2
754 | // --------
755 | //
756 | text = text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,
757 | function (wholeMatch, m1) { return "
" + _RunSpanGamut(m1) + "
\n\n"; }
758 | );
759 |
760 | text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,
761 | function (matchFound, m1) { return "" + _RunSpanGamut(m1) + "
\n\n"; }
762 | );
763 |
764 | // atx-style headers:
765 | // # Header 1
766 | // ## Header 2
767 | // ## Header 2 with closing hashes ##
768 | // ...
769 | // ###### Header 6
770 | //
771 |
772 | /*
773 | text = text.replace(/
774 | ^(\#{1,6}) // $1 = string of #'s
775 | [ \t]*
776 | (.+?) // $2 = Header text
777 | [ \t]*
778 | \#* // optional closing #'s (not counted)
779 | \n+
780 | /gm, function() {...});
781 | */
782 |
783 | text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,
784 | function (wholeMatch, m1, m2) {
785 | var h_level = m1.length;
786 | return "` blocks.
960 | //
961 |
962 | /*
963 | text = text.replace(/
964 | (?:\n\n|^)
965 | ( // $1 = the code block -- one or more lines, starting with a space/tab
966 | (?:
967 | (?:[ ]{4}|\t) // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
968 | .*\n+
969 | )+
970 | )
971 | (\n*[ ]{0,3}[^ \t\n]|(?=~0)) // attacklab: g_tab_width
972 | /g ,function(){...});
973 | */
974 |
975 | // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
976 | text += "~0";
977 |
978 | text = text.replace(/(?:\n\n|^\n?)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
979 | function (wholeMatch, m1, m2) {
980 | var codeblock = m1;
981 | var nextChar = m2;
982 |
983 | codeblock = _EncodeCode(_Outdent(codeblock));
984 | codeblock = _Detab(codeblock);
985 | codeblock = codeblock.replace(/^\n+/g, ""); // trim leading newlines
986 | codeblock = codeblock.replace(/\n+$/g, ""); // trim trailing whitespace
987 |
988 | codeblock = "
";
989 |
990 | return "\n\n" + codeblock + "\n\n" + nextChar;
991 | }
992 | );
993 |
994 | // attacklab: strip sentinel
995 | text = text.replace(/~0/, "");
996 |
997 | return text;
998 | }
999 |
1000 | function hashBlock(text) {
1001 | text = text.replace(/(^\n+|\n+$)/g, "");
1002 | return "\n\n~K" + (g_html_blocks.push(text) - 1) + "K\n\n";
1003 | }
1004 |
1005 | function _DoCodeSpans(text) {
1006 | //
1007 | // * Backtick quotes are used for " + codeblock + "\n
spans.
1008 | //
1009 | // * You can use multiple backticks as the delimiters if you want to
1010 | // include literal backticks in the code span. So, this input:
1011 | //
1012 | // Just type ``foo `bar` baz`` at the prompt.
1013 | //
1014 | // Will translate to:
1015 | //
1016 | //
foo `bar` baz
at the prompt.`bar`
...
1029 | //
1030 |
1031 | /*
1032 | text = text.replace(/
1033 | (^|[^\\]) // Character before opening ` can't be a backslash
1034 | (`+) // $2 = Opening run of `
1035 | ( // $3 = The code block
1036 | [^\r]*?
1037 | [^`] // attacklab: work around lack of lookbehind
1038 | )
1039 | \2 // Matching closer
1040 | (?!`)
1041 | /gm, function(){...});
1042 | */
1043 |
1044 | text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
1045 | function (wholeMatch, m1, m2, m3, m4) {
1046 | var c = m3;
1047 | c = c.replace(/^([ \t]*)/g, ""); // leading whitespace
1048 | c = c.replace(/[ \t]*$/g, ""); // trailing whitespace
1049 | c = _EncodeCode(c);
1050 | c = c.replace(/:\/\//g, "~P"); // to prevent auto-linking. Not necessary in code *blocks*, but in code spans. Will be converted back after the auto-linker runs.
1051 | return m1 + "" + c + "
";
1052 | }
1053 | );
1054 |
1055 | return text;
1056 | }
1057 |
1058 | function _EncodeCode(text) {
1059 | //
1060 | // Encode/escape certain characters inside Markdown code runs.
1061 | // The point is that in code, these characters are literals,
1062 | // and lose their special Markdown meanings.
1063 | //
1064 | // Encode all ampersands; HTML entities are not
1065 | // entities within a Markdown code span.
1066 | text = text.replace(/&/g, "&");
1067 |
1068 | // Do the angle bracket song and dance:
1069 | text = text.replace(//g, ">");
1071 |
1072 | // Now, escape characters that are magic in Markdown:
1073 | text = escapeCharacters(text, "\*_{}[]\\", false);
1074 |
1075 | // jj the line above breaks this:
1076 | //---
1077 |
1078 | //* Item
1079 |
1080 | // 1. Subitem
1081 |
1082 | // special char: *
1083 | //---
1084 |
1085 | return text;
1086 | }
1087 |
1088 | function _DoItalicsAndBold(text) {
1089 |
1090 | // must go first:
1091 | text = text.replace(/([\W_]|^)(\*\*|__)(?=\S)([^\r]*?\S[\*_]*)\2([\W_]|$)/g,
1092 | "$1$3$4");
1093 |
1094 | text = text.replace(/([\W_]|^)(\*|_)(?=\S)([^\r\*_]*?\S)\2([\W_]|$)/g,
1095 | "$1$3$4");
1096 |
1097 | return text;
1098 | }
1099 |
1100 | function _DoBlockQuotes(text) {
1101 |
1102 | /*
1103 | text = text.replace(/
1104 | ( // Wrap whole match in $1
1105 | (
1106 | ^[ \t]*>[ \t]? // '>' at the start of a line
1107 | .+\n // rest of the first line
1108 | (.+\n)* // subsequent consecutive lines
1109 | \n* // blanks
1110 | )+
1111 | )
1112 | /gm, function(){...});
1113 | */
1114 |
1115 | text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,
1116 | function (wholeMatch, m1) {
1117 | var bq = m1;
1118 |
1119 | // attacklab: hack around Konqueror 3.5.4 bug:
1120 | // "----------bug".replace(/^-/g,"") == "bug"
1121 |
1122 | bq = bq.replace(/^[ \t]*>[ \t]?/gm, "~0"); // trim one level of quoting
1123 |
1124 | // attacklab: clean up hack
1125 | bq = bq.replace(/~0/g, "");
1126 |
1127 | bq = bq.replace(/^[ \t]+$/gm, ""); // trim whitespace-only lines
1128 | bq = _RunBlockGamut(bq); // recurse
1129 |
1130 | bq = bq.replace(/(^|\n)/g, "$1 ");
1131 | // These leading spaces screw with content, so we need to fix that:
1132 | bq = bq.replace(
1133 | /(\s*
[^\r]+?<\/pre>)/gm,
1134 | function (wholeMatch, m1) {
1135 | var pre = m1;
1136 | // attacklab: hack around Konqueror 3.5.4 bug:
1137 | pre = pre.replace(/^ /mg, "~0");
1138 | pre = pre.replace(/~0/g, "");
1139 | return pre;
1140 | });
1141 |
1142 | return hashBlock("
\n" + bq + "\n
");
1143 | }
1144 | );
1145 | return text;
1146 | }
1147 |
1148 | function _FormParagraphs(text, doNotUnhash) {
1149 | //
1150 | // Params:
1151 | // $text - string to process with html