mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
Merge pull request #5169 from aereal/chrome-tabs-query-accepts-array-of-string
chrome: `url` property of QueryInfo can be a array of strings
This commit is contained in:
@@ -197,3 +197,55 @@ function proxySettings() {
|
||||
// clear with a scope set
|
||||
chrome.proxy.settings.clear({ scope: 'regular' });
|
||||
}
|
||||
|
||||
// https://developer.chrome.com/extensions/examples/api/contentSettings/popup.js
|
||||
function contentSettings() {
|
||||
var incognito;
|
||||
var url;
|
||||
|
||||
function settingChanged() {
|
||||
var type = this.id;
|
||||
var setting = this.value;
|
||||
var pattern = /^file:/.test(url) ? url : url.replace(/\/[^\/]*?$/, '/*');
|
||||
console.log(type+' setting for '+pattern+': '+setting);
|
||||
// HACK: [type] is not recognised by the docserver's sample crawler, so
|
||||
// mention an explicit
|
||||
// type: chrome.contentSettings.cookies.set - See http://crbug.com/299634
|
||||
chrome.contentSettings[type].set({
|
||||
'primaryPattern': pattern,
|
||||
'setting': setting,
|
||||
'scope': (incognito ? 'incognito_session_only' : 'regular')
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
chrome.tabs.query({active: true, currentWindow: true, url: ['http://*/*', 'https://*/*'] }, function(tabs) {
|
||||
var current = tabs[0];
|
||||
incognito = current.incognito;
|
||||
url = current.url;
|
||||
var types = ['cookies', 'images', 'javascript', 'location', 'plugins',
|
||||
'popups', 'notifications', 'fullscreen', 'mouselock',
|
||||
'microphone', 'camera', 'unsandboxedPlugins',
|
||||
'automaticDownloads'];
|
||||
types.forEach(function(type) {
|
||||
// HACK: [type] is not recognised by the docserver's sample crawler, so
|
||||
// mention an explicit
|
||||
// type: chrome.contentSettings.cookies.get - See http://crbug.com/299634
|
||||
chrome.contentSettings[type] && chrome.contentSettings[type].get({
|
||||
'primaryUrl': url,
|
||||
'incognito': incognito
|
||||
},
|
||||
function(details) {
|
||||
var input = <HTMLInputElement>document.getElementById(type);
|
||||
input.disabled = false;
|
||||
input.value = details.setting;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var selects = document.querySelectorAll('select');
|
||||
for (var i = 0; i < selects.length; i++) {
|
||||
selects[i].addEventListener('change', settingChanged);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
2
chrome/chrome.d.ts
vendored
2
chrome/chrome.d.ts
vendored
@@ -1900,7 +1900,7 @@ declare module chrome.tabs {
|
||||
active?: boolean;
|
||||
index?: number;
|
||||
title?: string;
|
||||
url?: string;
|
||||
url?: string | string[];
|
||||
currentWindow?: boolean;
|
||||
highlighted?: boolean;
|
||||
pinned?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user