Click here to Skip to main content
16,022,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am use Windows 7 64 bit & VS 2019. Save the W7 comments please

Because Google has forced users to use Chrome to view YouTube videos I have made some changes to a VB.Net app I wrote that
stores url links in a SQLite DB when the link is selected from
a DGV the YouTube channel opens in chrome now.

I would like to have VB.Net or C# code to Clear Browsing Data
in chrome when I exit the app.

Below is the code that closes the app with my feeble attempt
at Clearing Browsing Data

IMPROVE Question Idea
OK I assume that chrome shows a Web Page written in JavaScript to let me click a button to Clear Browsing Data SO if I can embed JS code in my VB.Net app I should be able to mimic the JS code chrome uses ? ? Issue I know very limited JS and embedding the code way beyond my pay grade! Back to searching this idea.
Suggestions about this approach would be helpful I am not asking for anyone to write my code just comment on this approach or point me to worthwhile resources Thanks

Second IMPROVED "Updated What I Have Tried"

What I have tried:

Here is what I have accomplished. I have found the path to where Google Chrome keeps Cache_Data and how to manipulate the data in the folder "code below" What I do not know and am not sure I want to test deleting the files in this folder
Que the Knees Knocking. When I use the Google settings to clear browser data all the files named f_00000a format are removed but the files named data_0 up to data_3 & index are NOT deleted
Question is If I delete all the files in the folder will the necessary files data_0 & index get recreated ? And
Filter deleting only the files with this named structure f_00000a ?
Dim aE As String
''aE = "C:\Users\Dwight\AppData\Local\Google\Chrome\User Data\Default\Cache\Cache_Data"
aE = "C:\A A A Junk"
''lk = "chrome.exe"

If Asc(e.KeyChar) = 27 Then

    Process.Start(aE)
    If My.Computer.FileSystem.FileExists("") Then  ' Then 'Check whether file exists
    End If
    'My.Computer.FileSystem.CopyFile("C:\A A A JunkTwo\f_00000a", "C:\A A A Junk\f_00000a")
    My.Computer.FileSystem.CopyDirectory("C:\A A A Junk", "C:\A A A JunkTwo", True)
    'My.Computer.FileSystem.DeleteFile("C:\A A A JunkTwo\f_00000a") 'Delete the file!

End If
Posted
Updated 7-Jul-24 14:37pm
v3
Comments
Dave Kreskowiak 6-Jul-24 19:23pm    
You're not being forced to use Chrome to view YouTube videos. They work just fine on every other browser I try.

What I suspect is happening is when Chrome gets updated, the handler for html pages gets switched back to Chrome from whatever you had before.
Choroid 6-Jul-24 21:37pm    
My Bad Dave the original app was trying to open using Firefox which was the default browser so YouTube would see Firefox and just not play the video because Google see's Firefox as Ad blocker. Yes I now call chrome.exe + the URL to the YT channel
Dave Kreskowiak 7-Jul-24 10:58am    
YouTube in FireFox works just fine, unless you actually have an ad-blocker turned on.
Choroid 7-Jul-24 12:15pm    
I will explore if Ad blocker is turned ON in Firefox but last time I looked I did not see any ON/OFF setting for Ad Blocker I have Version 115.12 ESR because I have W7
Richard Deeming 8-Jul-24 3:35am    
Using the ESR version is more likely to be the problem - perhaps Google updated the YouTube scripts so that they only work in recent browser versions?

Try checking the developer console to see if you're getting any errors. And see if you get the same problems using the current or dev version of Firefox.

1 solution

If your app clears the browser data every time it runs, then you're going to seriously annoy any users who are actually using Chrome as their default browser.

Rather than trying to mess up the browser settings, why not launch Chrome in "incognito" mode to view your pages? The --incognito command-line argument should accomplish that.
 
Share this answer
 
Comments
Choroid 8-Jul-24 13:54pm    
Richard I will only annoy me! I tried to use this code to launch Chrome in incognito mode BIG Fail any thoughts ?
Process.Start("Chrome.exe" + " --incognito", webPAGE)
I opened Developer Tools and see 10 errors a lot of web page code not seeing the exact errors highlighted will explore further Thanks for the Reply
Richard Deeming 9-Jul-24 4:03am    
You need to pass --incognito in the arguments, not the filename.
Process.Start("chrome.exe", "--incognito " & webPAGE)
Choroid 9-Jul-24 12:47pm    
Richard I think this Answer is for my other Question which you answered
https://www.codeproject.com/Questions/5384972/Open-webpage-incognito-mode-max-size-FAIL
I am still working on deleting files and not sure I should do that without understanding what happens if all the files are deleted only need to delete the ones that start with the letter "f" Work in Progress

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900