UseMyComputer Images

By Anmar Mansur Last update Dec 1, 2011 — Installed 2,423 times.

There are 2 previous versions of this script.

// ==UserScript==
// @name           UseMyComputer Images
// @description    Rewrites links on UseMyComputer.com to point directly to images and redirects external links.
// @include        http://usemycomputer.com/*
// @include        http://ump.usemycomputer.com/*
// @include        http://forum.usemycomputer.com/*
// @include        http://www.google.com/reader/*
// @include        https://www.google.com/reader/*
// ==/UserScript==

if (location.href.match(/^http:\/\/(?:ump\.)?usemycomputer\.com\/show\.html.*\/(?:indeximages|galleries)\//)) {
  // PLAN A - Redirect to Images: Works for external links from other sites.
  //GM_log("plan a");
  location.replace(location.href.replace(/^http:\/\/(ump\.)?usemycomputer\.com\/.*\/(indeximages|galleries)\//, "http://$1usemycomputer.com/$2/"));
} else if (location.href.match(/^http:\/\/(?:ump\.)?usemycomputer\.com\//)) {
  // PLAN B - Rewrite Image Links: Works for internal links within usemycomputer.com.
  //GM_log("plan b");
  var links = document.evaluate(".//a[contains(@href, '/show.html')]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  for (var i = 0; i < links.snapshotLength; i++) {
    links.snapshotItem(i).href = links.snapshotItem(i).href.replace(/^http:\/\/(ump\.)?usemycomputer\.com\/.*\/(indeximages|galleries)\//, "http://$1usemycomputer.com/$2/");
  }
} else if (location.href.match(/^https?:\/\/www\.google\.com\/reader\//)) {
  // PLAN C - Rewrite Dynamic Links: Works for dynamically loaded links in Google Reader.
  //GM_log("plan c");
  document.addEventListener("DOMNodeInserted", function(evt) {
    //GM_log("event triggered");
    var links = document.evaluate(".//a[contains(@href, 'usemycomputer.com') and contains(@href, '/show.html')]", evt.target, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
    for (var i = 0; i < links.snapshotLength; i++) {
      links.snapshotItem(i).href = unescape(links.snapshotItem(i).href).replace(/^http:\/\/(ump\.)?usemycomputer\.com\/.*\/(indeximages|galleries)\//, "http://$1usemycomputer.com/$2/");
    }
  }, false);
}