Alldatasheet.com: Decrapify and move search results to top

Move search to top, remove questionably-useful inventory and distributor search, remove gratuitous line breaks.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Alldatasheet.com: Decrapify and move search results to top
// @description Move search to top, remove questionably-useful inventory and distributor search, remove gratuitous line breaks.
// @namespace   giferrari.net
// @include     http://*.alldatasheet.com/*
// @version     2
// @grant       none
// @require       http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.js
// ==/UserScript==

// Of note: almost every darn thing on this page is wrapped in its own table.
// They went really overboard here... even the headers are their own tables.
// This is why there's a bunch of .closest('table') going on.

// *** Remove gratuitous line breaks. ***
$('body br').remove();

// *** Prevent gratuitous new windows
$('[target="_blank"]').prop('target', '');

// *** Remove the inventory sections ***.

// Hide the headers.
var inventoryHeaders = $('.h2view:contains("Inventory")').closest('table');
inventoryHeaders.hide();
//Now hide the actual inventory tables.
inventoryHeaders.next('table').hide();
// Since we only have one section remaining, hide the header for the real datasheet section.
$('.h2view:contains(" Datasheets")').closest('table').hide();


// *** Move the datasheet results to the top ***
// Easy way is to move the search refinement box down to where the link share box is.

// Find some bits of the DOM we need.
var datasheetResultsHeader = $('td:contains("Search ")').closest('table');
var datasheetResults = datasheetResultsHeader.next('table');

var searchRefinementBox = $('#tdnews').closest('table');
var linkBox = $('form[name="Linkurl"]').closest('table');

// Move the search refinement box down by the link share box at the bottom.
linkBox.prev().before(searchRefinementBox);

$('#layer1').remove();
$('#abc').remove(); // Yes, there's a random DIV with an ID of abc. Nix.

// Get rid of manufacturer noise
var manufacturersHeaderTable = $('td b').filter(function() { return $(this).text().endsWith(' Manufacturer'); }).closest('table');
manufacturersHeaderTable.next('table').remove();
manufacturersHeaderTable.remove();

$('.h2view:contains(" Distributor")').closest('table').remove();