Unsurly

Rewrites sur.ly links back to their original form

اعتبارا من 04-09-2016. شاهد أحدث إصدار.

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name        Unsurly
// @namespace   binoc.software.projects.userscript.unsurly
// @description Rewrites sur.ly links back to their original form
// @include     http://forum.palemoon.org/*
// @include     https://forum.palemoon.org/*
// @version     1.0a4
// @grant       none
// ==/UserScript==

// Polyfill ES6 string.prototype.includes
if (!String.prototype.includes) {
  String.prototype.includes = function(search, start) {
    'use strict';
    if (typeof start !== 'number') {
      start = 0;
    }
    
    if (start + search.length > this.length) {
      return false;
    } else {
      return this.indexOf(search, start) !== -1;
    }
  };
}

// Actual Script
function funcRewriteSurly() {
    var links, thisLink;
    links = document.evaluate("//a[@href]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

    for (var i=0;i<links.snapshotLength;i++) {
        var thisLink = links.snapshotItem(i);
        
        if (thisLink.href.includes('outbound.palemoon.org')) {
            thisLink.href = thisLink.href.replace('https://outbound.palemoon.org/', 'http://');
            thisLink.href = unescape(thisLink.href);
        }
        else if (thisLink.href.includes('sur.ly')) {
            thisLink.href = thisLink.href.replace('sur.ly/o/', '');
            thisLink.href = thisLink.href.replace('/AA010667', '');
            thisLink.href = unescape(thisLink.href);
        }
    }
}

window.onload = funcRewriteSurly;