Alldatasheet.com: Single-click PDF access

On the search results page, clicking on the PDF icon will jump you straight to PDF view.

Stan na 24-04-2016. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        Alldatasheet.com: Single-click PDF access
// @description On the search results page, clicking on the PDF icon will jump you straight to PDF view.
// @namespace   giferrari.net
// @include     http://www.alldatasheet.com/view.jsp*
// @version     1
// @grant       none
// @require       http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.js
// ==/UserScript==

// Grab all links that appear to redirect to a PDF page.
// There isn't a class that we can key off of, so we look for all
// anchors that have a PDF icon in them.
var datasheetPdfLinks = $('img[src="http://other.alldatasheet.com/etc/electronic_parts_datasheet.gif"]').closest('a');

// Open in same window instead of a new one.
datasheetPdfLinks.attr('target', null)

// Go to the PDF page directly.
datasheetPdfLinks.attr('href', function(i, oldHref) {
  // From:
  // http://www.alldatasheet.com/datasheet-pdf/pdf/317775/COMSET/2N2222.html
  // To:
  //http://pdf1.alldatasheet.com/datasheet-pdf/view/317775/COMSET/2N2222.html
  
  return oldHref
   .replace(/^http:\/\/www.alldatasheet.com/, 'http://pdf1.alldatasheet.com')
   .replace(/\/pdf\//, '/view/');
});