PySide Qt Document Links

Add PySide/Qt document cross reference links

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==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();
}