4

Im trying to make a google chrome extension that deletes all browsing history with one click on a icon located next to the url bar, this is my first extension on google chrome, i've made others for firefox, and i would like some guidance and ideas i think im quite close to my goal or at least in the right path, my current issue is the javascript document i know im missing code.

Javascript [TEST.js]

function TESTh() {
  chrome.history.deleteAll()
}
chrome.browserAction.onClicked.addListener(TESTh);
TESTh();

Manifest [manifest.json]

{
  "name": "TITLE TEST",
  "version": "1.0",
  "manifest_version": 2,
  "description": "DESCRIPTION TEST",
  "background": {
    "scripts": ["TEST.js"]
  },
  "browser_action": {
    "default_icon": "icon.png"
  },
  "permissions": [
    "history"
  ]
}

The following links are the tutorials i've been reading

http://developer.chrome.com/extensions/getstarted.html
http://developer.chrome.com/extensions/history.html
http://developer.chrome.com/extensions/browserAction.html
http://developer.chrome.com/extensions/samples.html
https://www.youtube.com/user/GoogleDevelopers

Thanks in advance

Minnen
  • 441
  • 8
  • 27

1 Answers1

4

I have written a sample trivial demonstration of Browsing Data API, it can help you to pick from here. Deletion may take time so you have to wait for message "All data is Deleted..." in console of extension for confirmation.

Before:

enter image description here

After:

enter image description here

manifest.json

{
  "name" : "BrowsingData Demo",
  "version" : "1",
  "description" : "Trivial Demonstration of Browsing Data",
  "permissions": [
    "browsingData"
  ],
  "browser_action": {
     "default_icon": "icon.png",
     "default_popup": "popup.html"
  },
  "manifest_version": 2
}

popup.html

<html>
<head>
<script src="popup.js"></script>
</head>
<body>
</body>
</html>

popup.js

   function browsingdata(){
    chrome.browsingData.remove({
      "originTypes": {
        "protectedWeb": true, // Set to true or true as per your requirement
        "unprotectedWeb":true,// Set to true or true as per your requirement
        "extension":true    // Set to true or true as per your requirement
      }
    }, {
      "appcache": true, // Set to true or true as per your requirement
      "cache": true, // Set to true or true as per your requirement
      "cookies": true, // Set to true or true as per your requirement
      "downloads": true, // Set to true or true as per your requirement
      "fileSystems": true, // Set to true or true as per your requirement
      "formData": true, // Set to true or true as per your requirement
      "history": true, // Set to true or true as per your requirement
      "indexedDB": true, // Set to true or true as per your requirement
      "localStorage": true, // Set to true or true as per your requirement
      "pluginData": true, // Set to true or true as per your requirement
      "passwords": true, // Set to true or true as per your requirement
      "webSQL": true // Set to true or true as per your requirement
    }, function (){
        console.log("All data is Deleted...");
    });
}
window.onload=browsingdata;

For more information refer browsing data API to get idea of all methods etc.

Sudarshan
  • 18,140
  • 7
  • 53
  • 61
  • Thanks @Sudarshan, that example indeed gave me a few ideas, too bad i couldn't make it work, i tried to "reverse engineer" the native Google chrome option to clear the browsing data [CTRL+SHIT+DEL or Menu/Tools/Clear browser data...] and i haven't read it all yet but i think there might be some useful stuff there, i also found this http://goo.gl/SXKpE wich is a chromium dev site and i got a few ideas from there too but im STILL FAR FROM SOLVING this :( – Minnen Nov 26 '12 at 19:55
  • 1
    @Minnen: I have edited my answer with working version, it will simply delete every thing from your browser(set flags to false where ever necessary) – Sudarshan Nov 27 '12 at 02:28
  • Thanks! @Sudarshan, being absolutely honest, i didn't properly read the link u provided in the [answer](https://developer.chrome.com/extensions/browsingData.html), mea culpa, your first example did worked after all and that link had all the information i needed, thanks! i wish i could give you points :(, anyway i will add you info on the extension as dev (if you're ok with it), i will go head and make the options panel so users can choose which data they want to delete. – Minnen Nov 27 '12 at 04:07