GoogleChrome扩展程序,只需点击一下图标即可删除浏览历史记录 [英] GoogleChrome extension that deletes browsing history with one click from an icon

查看:239
本文介绍了GoogleChrome扩展程序,只需点击一下图标即可删除浏览历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图制作一个谷歌浏览器扩展程序,只需点击位于url栏旁边的图标即可删除所有浏览历史记录,这是我在谷歌浏览器上的第一个扩展程序,我为Firefox做了其他的扩展程序,并且我希望一些指导和想法我认为我的目标非常接近我的目标,或者至少在正确的道路上,我当前的问题是我知道的即将缺少代码的javascript文档。

Javascript [ TEST.js]

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

Manifest [manifest.json]

<$ p
name:TITLE TEST,
version:1.0,
manifest_version:2,
描述:DESCRIPTION TEST,
background:{
scripts:[TEST.js]
},
browser_action:{
default_icon:icon.png
},
权限:[
历史
]
}

$ b $ p


pre





$ p $ 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

提前致谢

解决方案

<我已经写了一个Browsing Data API的示例演示,它可以帮助你从这里挑选。删除可能需要一些时间,因此您必须等待消息所有数据已删除...在扩展控制台中进行确认。



之前:





之后: b



清单.json

  {
name:BrowsingData Demo,
version:1,
description:浏览数据的简单演示,
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



pre $ function browsingdata(){
chrome.browsingData.remove({
originTypes:{
protectedWeb:true,//根据您的需求设置为true或true
unprotectedWeb:true,//根据您的需求设置为true或true
extension:true // Set to true或true根据您的需求
}
},{
appcache:true,//根据您的需求设置为true或true
cache:true, //根据您的需求设置为true或true
cookies:true,//根据您的需求设置为true或true
downloads:true,//设置为true或true根据您的需求
fileSystems:true,//设置为true或true
formData:true,//根据您的需求设置为true或true
历史:true,//根据您的要求设置为true或true
indexedDB:true,//根据您的需求设置为true或true
localStorage:true,//根据您的需求设置为true或true
pluginData:true,//根据您的需求设置为true或true
passwords:true,//根据您的需求设置为true或true
webSQL:true //根据您的要求设置为true或true
},function(){
console.log(All data is Deleted ...);
});
}
window.onload = browsingdata;

有关更多信息,请参阅浏览数据API ,以了解所有方法等。


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

解决方案

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:

After:

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.

这篇关于GoogleChrome扩展程序,只需点击一下图标即可删除浏览历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆