Filter by resolution

Позволяет исключать из поиска картинки с разрешением ниже указанного (при этом, не исключая более высокие)

目前為 2022-12-24 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Filter by resolution
  3. // @name:ru Фильтр по разрешению
  4. // @namespace http://tampermonkey.net/
  5. // @version 1.0
  6. // @description Позволяет исключать из поиска картинки с разрешением ниже указанного (при этом, не исключая более высокие)
  7. // @description:ru
  8. // @author Титан
  9. // @match https://yandex.ru/images/*
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=yandex.ru
  11. // @grant GM_registerMenuCommand
  12. // @license CC BY-NC-SA
  13. // ==/UserScript==
  14.  
  15. GM_registerMenuCommand("Delete all images with res below", DeleteImagesWithResBelow)
  16.  
  17. function DeleteImagesWithResBelow() {
  18.  
  19. let images = document.querySelectorAll(".serp-item__preview")
  20. let minRes = prompt("Enter min resolution with space (example: 1920 1080)")
  21. let minWidth = Slice(minRes, 0, " ")
  22. let minHeight = Slice(minRes, " ")
  23.  
  24. for (let image of images) {
  25. let size = image.querySelector(".serp-item__meta").textContent.replace(/[^\d.×]/g, '')
  26. if (size == null || size == "")
  27. continue;
  28. let width, height
  29. try {
  30. width = parseInt(Slice(size, 0, "×"))
  31. height = parseInt(Slice(size, "×"))
  32. } catch (e) {
  33. console.log("Error: " + e)
  34. console.log(image)
  35. }
  36.  
  37. if (width < minWidth || height < minHeight) image.parentNode.remove()
  38. }
  39.  
  40. for (let ad of document.querySelectorAll(".incut_inserted_yes")) {
  41. ad.remove()
  42. }
  43. }
  44.  
  45. function Slice(Source, Start, End = undefined) {
  46. let start, end, result = Source
  47. switch (typeof (Start)) {
  48. case "number":
  49. start = Start;
  50. break;
  51.  
  52. case "string":
  53. start = Source.indexOf(Start);
  54. start = start === -1 ? undefined : start + Start.length;
  55. break;
  56.  
  57. case "undefined":
  58. start = 0;
  59. break;
  60. }
  61. if (start === undefined) throw `can't find start "${Start}" of "${Source}"`
  62. result = result.slice(start)
  63.  
  64. switch (typeof (End)) {
  65. case "number":
  66. end = End;
  67. break;
  68.  
  69. case "string":
  70. end = Source.indexOf(End);
  71. if (end === -1) end = undefined;
  72. break;
  73.  
  74. case "undefined":
  75. end = Source.length;
  76. }
  77.  
  78. if (end === undefined) throw `can't find end "${End}" of "${Source}"`
  79. result = result.slice(0, end)
  80. return result;
  81.  
  82.  
  83. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址