Reddit Table Sort

Makes all the tables sortable

As of 07. 12. 2021. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Reddit Table Sort
// @author      sharadcodes
// @version     1.0.1
// @namespace   https://sharadcodes.github.io
// @supportURL   https://github.com/sharadcodes/UserScripts/issues
// @match       *://*reddit.com/*
// @include     https://*.reddit.com/*
// @include     https://reddit.com/*
// @description Makes all the tables sortable
// @license     MIT
// @grant       none
// ==/UserScript==


(function() {
  var JS_SCRIPTS = [
    'https://sharadcodes.github.io/UserScripts/COMMON/js/libs/sortable.js'
  ]
  
  JS_SCRIPTS.forEach(function(js_script) {
    GM_xmlhttpRequest(
      {
        method: 'GET',
        url: js_script + '?time=' + Date.now(),
        onload: function(response) {
          var custom_js_script = document.createElement('script'); 
          custom_js_script.textContent = response.responseText
          document.head.appendChild(custom_js_script);
          document.querySelectorAll('table').forEach(function(table) {
            table.setAttribute('data-sortable','');
            table.querySelector('thead').style.cursor = 'pointer';
            Sortable.init();
          })
        }
      }
    );
  })
})();