Hacker News

Add a link in the top banner of [Hacker News discussion](http://news.ycombinator.com/) to its counter part at [HN Premii](http://hn.premii.com/)

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 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        Hacker News
// @namespace   com.ycombinator.news
// @include     https://news.ycombinator.com/*
// @version     2.0
// @grant       none
// @description Add a link in the top banner of [Hacker News discussion](http://news.ycombinator.com/) to its counter part at [HN Premii](http://hn.premii.com/)
// ==/UserScript==

function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}

function readerUrl(id)
{
  var url = 'http://hn.premii.com/';
  if (id !== null && id.length > 0)
  {
    url += '#/comments/' + id;
  }
  return url;
}


var id = getParameterByName("id", window.location.href);
var readerLink = ' | <a href="' + readerUrl(id) + '">Reader</a>';
var topMenu = document.getElementsByClassName('pagetop') [0];
topMenu.innerHTML += readerLink;