Advertisement
A_GUES

Lna AdBlocker

May 30th, 2023
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.37 KB | None | 0 0
  1. -- 1. Identify the elements that represent ads on a webpage
  2. -- In this example, we'll target elements with CSS classes that often indicate ads.
  3.  
  4. local adClassNames = {
  5.   'ad',
  6.   'ad-banner',
  7.   'ad-container',
  8.   -- Add more class names as needed to cover different types of ads
  9. }
  10.  
  11. -- 2. Define a function to remove ads
  12.  
  13. local function removeAds()
  14.   -- Iterate through all elements in the workspace and check if they have ad-related class names
  15.   local elements = workspace:GetDescendants()
  16.   for i = 1, #elements do
  17.     local element = elements[i]
  18.     for j = 1, #adClassNames do
  19.       if element:IsA("GuiObject") and element.ClassName == adClassNames[j] then
  20.         element:Destroy()
  21.         break -- Once an ad is removed, no need to check other class names for the same element
  22.       end
  23.     end
  24.   end
  25. end
  26.  
  27. -- 3. Attach the removeAds function to relevant events, such as player joined or GUI changes
  28.  
  29. game.Players.PlayerAdded:Connect(removeAds)
  30. -- You can also listen for other events like PlayerGuiChanged, ScrollingFrame events, or AJAX requests
  31. -- and call removeAds() accordingly to handle dynamically loaded ads.
  32.  
  33. -- 4. (Optional) Create a button or trigger to manually remove ads
  34.  
  35. local adBlockButton = Instance.new("TextButton")
  36. adBlockButton.Text = "Toggle Ad Blocker"
  37. adBlockButton.MouseButton1Click:Connect(removeAds)
  38. adBlockButton.Parent = script.Parent
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement