Preferences button for Safari

Brings back the possibility to click a checkbox which opens the extension
settings from Safari's Preferences/Extensions.
This commit is contained in:
Deathamns 2014-11-05 17:01:18 +01:00
parent e36c7022cf
commit 6f2e449e61
8 changed files with 65 additions and 10 deletions

View File

@ -16,7 +16,10 @@
},
"safariextz": {
"app_id": "net.gorhill.uBlock",
"manifest": "Info.plist",
"manifest": {
"Info": "Info.plist",
"Settings": "Settings.plist"
},
"file_ext": ".safariextz",
"developer_identifier": "",
"cert_dir": "../meta/safariextz/certs/",

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>DefaultValue</key>
<false/>
<key>FalseValue</key>
<false/>
<key>Key</key>
<string>open_prefs</string>
<key>Secure</key>
<false/>
<key>Title</key>
<string>Click to see the Preferences</string>
<key>TrueValue</key>
<true/>
<key>Type</key>
<string>CheckBox</string>
</dict>
</array>
</plist>

View File

@ -15,7 +15,7 @@
<key>CFBundleShortVersionString</key>
<string>0.7.0.9</string>
<key>CFBundleVersion</key>
<string>1455205</string>
<string>1455425</string>
<key>Chrome</key>
<dict>
<key>Database Quota</key>

22
src/Settings.plist Normal file
View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>DefaultValue</key>
<false/>
<key>FalseValue</key>
<false/>
<key>Key</key>
<string>open_prefs</string>
<key>Secure</key>
<false/>
<key>Title</key>
<string>Click to see the Preferences</string>
<key>TrueValue</key>
<true/>
<key>Type</key>
<string>CheckBox</string>
</dict>
</array>
</plist>

View File

@ -287,6 +287,12 @@ if (self.chrome) {
]
);
safari.extension.settings.addEventListener('change', function(e) {
if (e.key === 'open_prefs') {
vAPI.tabs.open({url: 'dashboard.html', active: true});
}
}, false);
vAPI.storage = {
_storage: safari.extension.settings,

View File

@ -56,10 +56,10 @@ if (self.chrome) {
vAPI.chrome = true;
vAPI.messaging = {
port: null,
channels: {},
listeners: {},
requestId: 0,
connectorId: uniqueId(),
listeners: {},
channels: {},
connector: messagingConnector,
setup: function() {
this.port = chrome.runtime.connect({name: this.connectorId});
@ -111,10 +111,10 @@ if (self.chrome) {
// relevant?
// https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/MessagesandProxies/MessagesandProxies.html#//apple_ref/doc/uid/TP40009977-CH14-SW12
vAPI.messaging = {
connectorId: uniqueId(),
requestId: 0,
listeners: {},
channels: {},
listeners: {},
requestId: 0,
connectorId: uniqueId(),
connector: messagingConnector,
setup: function() {
this._connector = function(msg) {

View File

@ -5,7 +5,7 @@ import re
import json
from time import strftime
from datetime import datetime
from shutil import rmtree as rmt
from shutil import rmtree as rmt, copy
from collections import OrderedDict
from xml.sax.saxutils import escape
@ -99,11 +99,13 @@ with open(pj(src_dir, vendors['crx']['manifest']), 'wt', encoding='utf-8', newli
)
with open(pj(src_dir, vendors['safariextz']['manifest']), 'wt', encoding='utf-8', newline='\n') as f:
with open(pj(src_dir, vendors['safariextz']['manifest']['Info']), 'wt', encoding='utf-8', newline='\n') as f:
config['app_id'] = vendors['safariextz']['app_id']
config['description'] = descriptions[config['def_lang']]
with open(pj(meta_dir, 'safariextz', vendors['safariextz']['manifest']), 'r') as cf:
with open(pj(meta_dir, 'safariextz', vendors['safariextz']['manifest']['Info']), 'r') as cf:
cf_content = cf.read()
f.write(cf_content.format(**config))
copy(pj(meta_dir, 'safariextz', vendors['safariextz']['manifest']['Settings']), pj(src_dir, vendors['safariextz']['manifest']['Settings']))