Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 1. Identify the elements that represent ads on a webpage
- -- In this example, we'll target elements with CSS classes that often indicate ads.
- local adClassNames = {
- 'ad',
- 'ad-banner',
- 'ad-container',
- -- Add more class names as needed to cover different types of ads
- }
- -- 2. Define a function to remove ads
- local function removeAds()
- -- Iterate through all elements in the workspace and check if they have ad-related class names
- local elements = workspace:GetDescendants()
- for i = 1, #elements do
- local element = elements[i]
- for j = 1, #adClassNames do
- if element:IsA("GuiObject") and element.ClassName == adClassNames[j] then
- element:Destroy()
- break -- Once an ad is removed, no need to check other class names for the same element
- end
- end
- end
- end
- -- 3. Attach the removeAds function to relevant events, such as player joined or GUI changes
- game.Players.PlayerAdded:Connect(removeAds)
- -- You can also listen for other events like PlayerGuiChanged, ScrollingFrame events, or AJAX requests
- -- and call removeAds() accordingly to handle dynamically loaded ads.
- -- 4. (Optional) Create a button or trigger to manually remove ads
- local adBlockButton = Instance.new("TextButton")
- adBlockButton.Text = "Toggle Ad Blocker"
- adBlockButton.MouseButton1Click:Connect(removeAds)
- adBlockButton.Parent = script.Parent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement