Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --20240522
- --simple script to loop every 4 seconds an add the UDM=14 argument into any google search on the active Safari tab. UDM=14 applies web search which gets rid of a lot of Google cruft
- set udmImage to "&udm=2" --udm of image search
- set udmWeb to "&udm=14" --udm of web search
- set tbmVideo to "&tbm=vid" --argument for video search (I believe)
- set tbmNews to "&tbm=nws" --argument for news search
- set approvedUDMs to {tbmVideo, tbmNews, udmImage, udmWeb} --the list of search types that are OK
- --can add more UDMs that are approved, but I don't use them so I haven't investigated
- set lengthOfApprovedUDMs to length of approvedUDMs
- repeat
- delay 4 --check every 4 seconds (can be changed, but 4 secs is low impact)
- tell application "System Events" to set frontmostProcess to first process whose frontmost is true
- if name of frontmostProcess is "Safari" then
- tell application "Safari"
- set theURL to URL of current tab of window 1
- --embed the udm=14 argument into a google search URL in safari as long as it's not already there and only if Safari is the frontmost app
- if theURL contains "google.com/search" and theURL does not contain "&udm=14" then
- set theURLisApproved to false
- set i to 1
- repeat while i β€ lengthOfApprovedUDMs and theURLisApproved is false
- if theURL contains item i of approvedUDMs then set theURLisApproved to true
- set i to i + 1
- end repeat
- if theURLisApproved is false then
- set theNewURL to theURL & "&udm=14"
- set URL of current tab of window 1 to theNewURL
- end if
- end if
- end tell
- end if
- end repeat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement