AZNude - Video Search & UI Tweaks

Search and cleaners

اعتبارا من 12-02-2019. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name          AZNude - Video Search & UI Tweaks
// @namespace     brazenvoid
// @version       2.0.3
// @author        brazenvoid
// @license       GPL-3.0-only
// @description   Search and cleaners
// @include       https://www.aznude.com/*
// @require       https://greasyfork.org/scripts/375557-brazenvoid-s-base-resource/code/Brazenvoid's%20Base%20Resource.js?version=658367
// @run-at	      document-end
// ==/UserScript==

// Settings & Defaults

let settings = {
  duration: { // In Seconds
    minimum: 30,
    maximum: 0,
  },
  showUIAlways: false, // Desktop Only
  removeAdBoxes: true,
  removeRecommendations: true,
  removeSponsoredVideos: true,
  debugLogging: false,
}

// Base Resource Initializations

const scriptPrefix = 'az-sui-'

let storage = new LocalStore(scriptPrefix + 'settings', settings)
settings = storage.retrieve().get()

let logger = new Logger(settings.debugLogging)
let selectorGenerator = new SelectorGenerator(scriptPrefix)
let statistics = new StatisticsRecorder(logger, selectorGenerator)
let filters = new Filters(statistics)
let uiGenerator = new UIGenerator(settings.showUIAlways, selectorGenerator)

let sponsoredRegex = new RegExp('azncdn', 'ig')

// Local Store Events

let refreshUI = function () {
  document.getElementById(selectorGenerator.getSettingsInputSelector('Min Duration')).value =
    this.get().duration.minimum
}
storage.onDefaultsLoaded = refreshUI
storage.onRetrieval = refreshUI
storage.onUpdated = refreshUI

// Validators
// -- Duration validation

let validateDuration = function (videoItem) {

  let videoDuration = videoItem.querySelector('.video-time')

  if ((settings.duration.minimum > 0 || settings.duration.maximum > 0) && (videoDuration !== null)) {

    videoDuration = videoDuration.textContent.split(':')
    videoDuration = (parseInt(videoDuration[0]) * 60) + parseInt(videoDuration[1])

    return filters.validateRange('Duration', videoDuration, [settings.duration.minimum, settings.duration.maximum])
  }
  return true
}

// -- Sponsored video validation

let validateSponsoredVideo = function (videoItem) {

  if (settings.removeSponsoredVideos) {

    let validationCheck = videoItem.querySelector('.show-clip').href.match(sponsoredRegex) !== null
    statistics.record('Sponsored', validationCheck)

    return validationCheck
  }
  return true
}

// -- Compliance logic

let complianceCallback = function () {

  let videoItems = document.querySelectorAll('.albuma2')
  let videoComplies

  for (let videoItem of videoItems) {

    videoComplies = validateDuration(videoItem) && validateSponsoredVideo(videoItem)

    if (videoComplies) {
      videoItem.style.display = 'inline-block'
    } else {
      videoItem.style.display = 'none'
    }

    logger.logSeparator()
  }
  statistics.updateUI()
}

// UI Composition
// -- Control Panel

let section = uiGenerator.createSection('settings', '#ffa31a', '200px', [
  uiGenerator.createSettingsFormGroup('Min Duration', settings.duration.minimum),
  uiGenerator.createFormButton('Apply', function () {

    settings.duration.minimum =
      document.getElementById(selectorGenerator.getSettingsInputSelector('Min Duration')).value

    statistics.reset()
    complianceCallback()
    statistics.updateUI()
  }),
  uiGenerator.createSeparator(),
  uiGenerator.createStoreUpdateButton(storage),
  uiGenerator.createStoreReloadButton(storage),
  uiGenerator.createStoreResetButton(storage),
  uiGenerator.createStoreDeleteButton(storage),
  uiGenerator.createSeparator(),
  uiGenerator.createStatisticsFormGroup('Duration', 'Short'),
  uiGenerator.createStatisticsFormGroup('Sponsored'),
  uiGenerator.createStatisticsFormGroup('Total'),
  uiGenerator.createFormButton('Hide', function () {
    document.getElementById(selectorGenerator.getSelector('settings')).style.display = 'none'
  }),
])
uiGenerator.appendToBody(section)

// -- Settings Button

let controlButton = uiGenerator.createSettingShowButton('Search & Tweaks', section)
uiGenerator.appendToBody(controlButton)

logger.logTaskCompletion('Building UI')

// Remove Ad Boxes

if (settings.removeAdBoxes) {

  let ads = document.querySelectorAll('.ad-box-video')

  for (const ad of ads) {
    ad.remove()
  }
}

// Remove Recommendations

if (settings.removeRecommendations) {

  let recommendationSections = document.querySelectorAll('.recommended')

  for (const recommendationSection of recommendationSections) {
    recommendationSection.remove()
  }
}

// Script run

complianceCallback()