AllDataSheet: straight to PDF

With this script you will directly go to the PDF version of the datasheet when you click on the PDF icon in the search results.

目前為 2021-06-10 提交的版本,檢視 最新版本

// ==UserScript==
// @name        AllDataSheet: straight to PDF
// @name:it     AllDataSheet: dritto al PDF
// @description With this script you will directly go to the PDF version of the datasheet when you click on the PDF icon in the search results.
// @description:it Con questo script andrai direttamente alla versione in PDF della scheda tecnica quando clicchi sull'icona del PDF nei risultati della ricerca.
// @namespace   StephenP
// @match     http://*.alldatasheet.com/*.jsp*
// @match     https://*.alldatasheet.com/*.jsp*
// @match     http://*.alldatasheet.com/datasheet-pdf/*
// @match     https://*.alldatasheet.com/datasheet-pdf/*
// @version     1
// @grant       none
// ==/UserScript==
if(window.location.href.includes("/datasheet-pdf/")){
  document.body.style.display="none"; //Not really necessary, but avoids misunderstanding on what the script is doing.
  var frames=document.getElementsByTagName("IFRAME");
  for(let frame of frames){
    if(frame.src.includes("/datasheet-pdf/")){
      window.location.href=frame.src;
    }
  }
}
else{  
  var images = document.getElementsByTagName("IMG");
  for(let image of images){
    if(image.src.includes("/electronic_parts_datasheet.gif")){
      image.parentNode.href=image.parentNode.href.replace("www.alldatasheet.com","pdf1.alldatasheet.com").replace("/pdf/","/view/");
    }
  }
}