mozillaZine Forums - inserts titles to bug links

Inserts titles to bug links that are plain URLs, in forums.mozillazine.org

目前為 2015-09-02 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        mozillaZine Forums - inserts titles to bug links
// @namespace   rikkie
// @description Inserts titles to bug links that are plain URLs, in forums.mozillazine.org
// @include     http://forums.mozillazine.org/viewtopic.php*
// @version     1.1
// @grant			  GM_xmlhttpRequest
// ==/UserScript==

var items = [];
var links = document.getElementsByClassName('postlink');


for (i = 0; i < links.length; i++) {
  if (links[i].innerHTML.match(/https:\/\/bugzilla\.mozilla\.org\/show_bug\.cgi\?id=*/)) {

    var elem = document.createElement("img");
    elem.setAttribute("src", "http://i.imgur.com/3Y8dqYZ.gif");
    links[i].parentNode.insertBefore(elem, links[i].nextSibling);
    
    
    
    insertTitle(links[i]);
  };
};


function insertTitle(x) {
  var details = GM_xmlhttpRequest({
    method: 'GET',
    url: x.innerHTML,
    synchronous: false,                         // Asynchronous request
    onload: function (response) {      
      var matches = response.responseText.match(/<title>(.*)<\/title>/);
      var regex = /<title>(.*)<\/title>/;
      var title = regex.exec(matches[0]);
      x.nextSibling.remove();
      x.innerHTML = title[1];
    }
  })
}