Greasy Fork 支持简体中文。

Alldatasheet.com: Decrapify and move search results to top

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

  1. // ==UserScript==
  2. // @name Alldatasheet.com: Decrapify and move search results to top
  3. // @description Move search to top, remove questionably-useful inventory and distributor search, remove gratuitous line breaks.
  4. // @namespace giferrari.net
  5. // @include http://*.alldatasheet.com/*
  6. // @version 2
  7. // @grant none
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.js
  9. // ==/UserScript==
  10.  
  11. // Of note: almost every darn thing on this page is wrapped in its own table.
  12. // They went really overboard here... even the headers are their own tables.
  13. // This is why there's a bunch of .closest('table') going on.
  14.  
  15. // *** Remove gratuitous line breaks. ***
  16. $('body br').remove();
  17.  
  18. // *** Prevent gratuitous new windows
  19. $('[target="_blank"]').prop('target', '');
  20.  
  21. // *** Remove the inventory sections ***.
  22.  
  23. // Hide the headers.
  24. var inventoryHeaders = $('.h2view:contains("Inventory")').closest('table');
  25. inventoryHeaders.hide();
  26. //Now hide the actual inventory tables.
  27. inventoryHeaders.next('table').hide();
  28. // Since we only have one section remaining, hide the header for the real datasheet section.
  29. $('.h2view:contains(" Datasheets")').closest('table').hide();
  30.  
  31.  
  32. // *** Move the datasheet results to the top ***
  33. // Easy way is to move the search refinement box down to where the link share box is.
  34.  
  35. // Find some bits of the DOM we need.
  36. var datasheetResultsHeader = $('td:contains("Search ")').closest('table');
  37. var datasheetResults = datasheetResultsHeader.next('table');
  38.  
  39. var searchRefinementBox = $('#tdnews').closest('table');
  40. var linkBox = $('form[name="Linkurl"]').closest('table');
  41.  
  42. // Move the search refinement box down by the link share box at the bottom.
  43. linkBox.prev().before(searchRefinementBox);
  44.  
  45. $('#layer1').remove();
  46. $('#abc').remove(); // Yes, there's a random DIV with an ID of abc. Nix.
  47.  
  48. // Get rid of manufacturer noise
  49. var manufacturersHeaderTable = $('td b').filter(function() { return $(this).text().endsWith(' Manufacturer'); }).closest('table');
  50. manufacturersHeaderTable.next('table').remove();
  51. manufacturersHeaderTable.remove();
  52.  
  53. $('.h2view:contains(" Distributor")').closest('table').remove();