PySide Qt Document Links

Add PySide/Qt document cross reference links

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        PySide Qt Document Links
// @namespace   qixinglu.com
// @description Add PySide/Qt document cross reference links
// @grant       none
// @include     http://qt-project.org/doc/qt-4.8/*.html*
// @include     http://srinikom.github.com/pyside-docs/PySide/*.html
// @version 0.0.1.20140517140355
// ==/UserScript==

function pyside_link() {
    var prefix = 'http://srinikom.github.com/pyside-docs/PySide/';
    var nodes = document.querySelectorAll('.product');
    var moduleName = nodes[1].textContent.trim();
    var objectName = nodes[2].textContent.replace('Class Reference', '').trim();
    var url = prefix + moduleName + '/' + objectName + '.html';
    var link = document.createElement('a');
    link.href = url;
    link.textContent = 'Pyside document page';
    var breadcrumb = document.querySelector('li.breadcrumbs-docscontainer');
    breadcrumb.replaceChild(link, breadcrumb.firstElementChild);
}

function qt_link() {
    var prefix = 'http://qt-project.org/doc/qt-4.8/';
    var objectName = document.querySelector('title').textContent.split(' ')[0];
    var url = prefix + objectName.toLowerCase() + '.html';
    var link = document.createElement('a');
    link.href = url;
    link.textContent = 'Qt document page';
    link.style.cssText = 'float: right; margin-right: 10px;';
    var h1Node = document.getElementsByTagName('h1')[0];
    h1Node.appendChild(link);
}

if (location.href.indexOf('qt-project.org') === -1) {
    qt_link();
} else {
    pyside_link();
}