Reddit Table Sort

Makes all the tables sortable

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey 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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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.3
// @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       GM_xmlhttpRequest
// ==/UserScript==


window.onload = 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();
          })
        }
      }
    );
  })
}