Advertisement
TealDeer

Color Quotes for Xkit

Jan 18th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE A NEW XKIT EXTENSION IN THE EDITOR BY CLICKING 'New Extension'. NAME IT 'colorquotes'.
  2.  
  3. IN THE SCRIPT TAB, PASTE THIS:
  4. //* TITLE Color Quotes **//
  5. //* VERSION 2.0.0 **//
  6. //* DESCRIPTION Colored quotes for the dash **//
  7. //* DETAILS Know those lines that appear when you reblog someone, when Tumblr quotes them? Sometimes, when a lot of people talk on the same post, it might be hard to keep track of those. This extension changes the color of each line (or their background, depending on your preferences) so you can read and differentiate them faster. **//
  8. //* DEVELOPER STUDIOXENIX **//
  9. //* FRAME false **//
  10. //* SLOW false **//
  11. //* BETA false **//
  12.  
  13. XKit.extensions.colorquotes = new Object({
  14.  
  15.     running: false,
  16.  
  17.     preferences: {
  18.         "sep-0": {
  19.             text: "When to run Color Quotes",
  20.             type: "separator"
  21.         },
  22.         "dont_fade_if_less_than_two": {
  23.             text: "Don't color the block quotes if there is only one",
  24.             default: true,
  25.             value: true
  26.         },
  27.         "sep-1": {
  28.             text: "Appearance",
  29.             type: "separator"
  30.         },
  31.         theme: {
  32.             text: "Color Theme",
  33.             default: "default",
  34.             value: "default",
  35.             type: "combo",
  36.             values: [
  37.                 "Default Rainbow", "default",
  38.                 "Pastel Rainbow", "pastel",
  39.                 "Tumblr Blue", "blue",
  40.                 "Grayscale", "grayscale",
  41.                 "Pink and Red", "pink",
  42.                 "Red and Gray", "rag",
  43.             ],
  44.         },
  45.         "do_backgrounds": {
  46.             text: "Use a faded color on block quote backgrounds too",
  47.             default: false,
  48.             value: false
  49.         },
  50.         "increase_padding": {
  51.             text: "Increase padding for easier reading",
  52.             default: false,
  53.             value: false
  54.         }
  55.     },
  56.  
  57.     colors: ["ff1900","ff9000","ffd000","6adc13","00cd8b","00a5e7","001999","cc00b9","ff78e1"],
  58.  
  59.     run: function() {
  60.         this.running = true;
  61.  
  62.         if (XKit.extensions.colorquotes.preferences.theme.value === "pastel") {
  63.             this.colors = ["e45c5c","ffcc66","d7e972","76e2c2","5dc6cd","be7ce4","e45c5c","ffcc66","d7e972"];
  64.         }
  65.  
  66.         if (XKit.extensions.colorquotes.preferences.theme.value === "blue") {
  67.             this.colors = ["36536e","536c83","6a8094","798c9f","36536e","536c83","6a8094","798c9f","36536e"];
  68.         }
  69.  
  70.         if (XKit.extensions.colorquotes.preferences.theme.value === "grayscale") {
  71.             this.colors = ["b2b2b2","969696","6b6b6b","3d3d3d","d3d0d0","b2b2b2","969696","6b6b6b","3d3d3d"];
  72.         }
  73.  
  74.         if (XKit.extensions.colorquotes.preferences.theme.value === "pink") {
  75.             this.colors = ["c53b3c","f09dd8","c53b3c","f09dd8","c53b3c","f09dd8","c53b3c","f09dd8"];
  76.         }
  77.  
  78.         if (XKit.extensions.colorquotes.preferences.theme.value === "rag") {
  79.             this.colors = ["e24545","acacac","e24545","acacac","e24545","acacac","e24545","acacac"];
  80.         }
  81.  
  82.         if (XKit.extensions.colorquotes.preferences.increase_padding.value === true) {
  83.             XKit.tools.add_css("#posts .post_content blockquote { padding-top: 8px; padding-bottom: 8px; }", "colorquotes_padding");
  84.         }
  85.  
  86.  
  87.  
  88.         if ($("#posts").length > 0) {
  89.             XKit.tools.init_css("colorquotes");
  90.             XKit.post_listener.add("colorquotes", XKit.extensions.colorquotes.do);
  91.             XKit.extensions.colorquotes.do();
  92.         }
  93.  
  94.     },
  95.  
  96.     do: function() {
  97.  
  98.         var posts = XKit.interface.get_posts("xkit-color-quoted");
  99.  
  100.         $(posts).each(function() {
  101.  
  102.             $(this).addClass("xkit-color-quoted");
  103.  
  104.             var m_post = XKit.interface.post($(this));
  105.  
  106.             var count = 0;
  107.  
  108.             if (XKit.extensions.colorquotes.preferences.dont_fade_if_less_than_two.value === true) {
  109.                 if ($(this).find("blockquote").length === 1) { return; }
  110.             }
  111.  
  112.             $(this).find("blockquote").each(function() {
  113.  
  114.                 if (count >= XKit.extensions.colorquotes.colors.length) { count = 0; }
  115.  
  116.                 var m_color = XKit.extensions.colorquotes.hex_to_rgb(XKit.extensions.colorquotes.colors[count]);
  117.  
  118.                 $(this).css("border-left-color", "#" + XKit.extensions.colorquotes.colors[count]);
  119.                 $(this).attr('xkit-border-color', JSON.stringify(m_color));
  120.                 $(this).addClass("xkit-colorquotes-border-item");
  121.  
  122.                 if (XKit.extensions.colorquotes.preferences.do_backgrounds.value === true) {
  123.                     $(this).css("background", "rgba(" + m_color.r + "," + m_color.g + "," + m_color.b + ",0.1)");
  124.                 }
  125.  
  126.                 count++;
  127.  
  128.             });
  129.  
  130.  
  131.         });
  132.  
  133.     },
  134.  
  135.     hex_to_rgb: function(hex) {
  136.  
  137.         // From: http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb
  138.  
  139.         var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  140.         return result ? {
  141.             r: parseInt(result[1], 16),
  142.             g: parseInt(result[2], 16),
  143.             b: parseInt(result[3], 16)
  144.         } : null;
  145.  
  146.     },
  147.  
  148.     destroy: function() {
  149.         $(".xkit-color-quoted").removeClass("xkit-color-quoted");
  150.         XKit.tools.remove_css("colorquotes_padding");
  151.         $(".xkit-colorquotes-border-item").css("background","").css("border-left-color","");
  152.         this.running = false;
  153.     }
  154.  
  155. });
  156.  
  157.  
  158. IN THE ICON TAB, PASTE THIS:
  159. data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAuxJREFUeAHtWz1rFFEUPe/N7Ed2JhoNJMb4iYLCIhq0EyGtoJUWwdbfYCNYCTb+BktDSsHCNiB2wSBiYaVRdE1gIepkXfdjnu/uZMzVGdcfcO8rZu68+z7uOffsdscAMI9vXDt94uyRlwc7vcj0rfFzfji46W+Yb3YQ1QMYszudJf3ToB1b2OYBRFFYyKcOePauh+WtAOFEMe+cQe9zE2jfRFiLCvv9drj3LdQ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