Started to add settings.
This commit is contained in:
parent
51819ac81b
commit
623d3ec596
17
License.txt
Normal file
17
License.txt
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
Copyright (c) 2010 Mr. Gecko's Media (James Coleman). All rights reserved. http://mrgeckosmedia.com/
|
||||||
|
|
||||||
|
Permission is granted, to any person obtaining a copy of this extension, to
|
||||||
|
use, copy, modify, merge, or redistribute this extension under the following terms:
|
||||||
|
|
||||||
|
1. THIS EXTENSION IS PROVIDED "AS IS" BY JAMES COLEMAN, WITHOUT WARRANTY OF
|
||||||
|
ANY KIND. IF YOUR SOFTWARE/EXTENSION/COMPUTER CRASH OR FAILS TO WORK IN ANY
|
||||||
|
WAY SHAPE OR FORM BECAUSE OF THIS EXTENSION, I (JAMES COLEMAN) AM NOT IN ANYWAY
|
||||||
|
RESPONSIBLE FOR YOUR PROBLEM. BUT, I MAY BE WILLING TO HELP YOU, NO PROMISES.
|
||||||
|
|
||||||
|
2. Redistributions of source code included in this extension must retain the
|
||||||
|
copyright notice above this license file without modifications.
|
||||||
|
|
||||||
|
3. Redistributions of binary must contain the copyright above this license file
|
||||||
|
without modifications.
|
||||||
|
|
||||||
|
4. Mr. Gecko's Media (James Coleman) is allowed to modify these terms with little or no notice to anyone.
|
@ -4,9 +4,29 @@
|
|||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
<key>DefaultValue</key>
|
<key>DefaultValue</key>
|
||||||
<string></string>
|
<false/>
|
||||||
|
<key>Key</key>
|
||||||
|
<string>invisible</string>
|
||||||
|
<key>Title</key>
|
||||||
|
<string>Load invisible flash automatically</string>
|
||||||
|
<key>Type</key>
|
||||||
|
<string>CheckBox</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>DefaultValue</key>
|
||||||
|
<string>vimeo.com,mrgeckosmedia.net</string>
|
||||||
<key>Key</key>
|
<key>Key</key>
|
||||||
<string>whitelist</string>
|
<string>whitelist</string>
|
||||||
|
<key>Title</key>
|
||||||
|
<string>White list</string>
|
||||||
|
<key>Type</key>
|
||||||
|
<string>Hidden</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>Key</key>
|
||||||
|
<string>blacklist</string>
|
||||||
|
<key>Type</key>
|
||||||
|
<string>Hidden</string>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
</plist>
|
</plist>
|
||||||
|
22
flashfire.js
22
flashfire.js
@ -26,10 +26,10 @@ function handleBeforeLoadEvent(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//console.log(safari.self.tab.canLoad(event, {name: "getSettings", data: ""}));
|
if (safari.self.tab.canLoad(event, {name: "getSetting", setting: "invisible"})==true && element.style.display=="none")
|
||||||
|
return;
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
blockElement(element);
|
blockElement(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,7 +83,6 @@ function displayContextMenu(event) {
|
|||||||
var element = event.target;
|
var element = event.target;
|
||||||
var left = event.pageX;
|
var left = event.pageX;
|
||||||
var top = event.pageY;
|
var top = event.pageY;
|
||||||
console.log(event);
|
|
||||||
while (element.className!="flashfireBlocked")
|
while (element.className!="flashfireBlocked")
|
||||||
element = element.parentNode;
|
element = element.parentNode;
|
||||||
|
|
||||||
@ -124,6 +123,23 @@ function displayContextMenu(event) {
|
|||||||
autoLoadElement.innerHTML = "Automatically Load Flash on "" + window.location.host + """;
|
autoLoadElement.innerHTML = "Automatically Load Flash on "" + window.location.host + """;
|
||||||
menuElement.appendChild(autoLoadElement);
|
menuElement.appendChild(autoLoadElement);
|
||||||
|
|
||||||
|
var autoHideElement = document.createElement("li");
|
||||||
|
autoHideElement.className = "flashfireMenuItem";
|
||||||
|
autoHideElement.innerHTML = "Automatically Hide Flash on "" + window.location.host + """;
|
||||||
|
menuElement.appendChild(autoHideElement);
|
||||||
|
|
||||||
|
var prefSeparatorElement = document.createElement("li");
|
||||||
|
prefSeparatorElement.className = "flashfireMenuSeparator";
|
||||||
|
menuElement.appendChild(prefSeparatorElement);
|
||||||
|
|
||||||
|
var preferencesElement = document.createElement("li");
|
||||||
|
preferencesElement.className = "flashfireMenuItem";
|
||||||
|
preferencesElement.innerHTML = "FlashFire Preferences...";
|
||||||
|
var prefWidth = 445;
|
||||||
|
var prefHeigth = 500;
|
||||||
|
preferencesElement.onclick = function() {window.open(safari.extension.baseURI + "preferences.html", "FlashFire Preferences", "width=" + prefWidth + ",height=" + prefHeigth + ",left=" + (screen.availWidth-prefWidth)/2 + ",top=" + (screen.availHeight-prefHeigth)/2 + ",resizable=no,scrollbars=no,menubar=no,status=no,location=no")}
|
||||||
|
menuElement.appendChild(preferencesElement);
|
||||||
|
|
||||||
document.body.appendChild(menuElement);
|
document.body.appendChild(menuElement);
|
||||||
|
|
||||||
var closeContentMenu = function(event) {
|
var closeContentMenu = function(event) {
|
||||||
|
18
global.html
18
global.html
@ -2,15 +2,25 @@
|
|||||||
<script>
|
<script>
|
||||||
safari.application.addEventListener("message", handleMessage, false);
|
safari.application.addEventListener("message", handleMessage, false);
|
||||||
|
|
||||||
|
var FFWhitelist = safari.extension.settings["whitelist"].split(",");
|
||||||
|
var FFBlacklist = safari.extension.settings["blacklist"].split(",");
|
||||||
|
|
||||||
function handleMessage(theEvent) {
|
function handleMessage(theEvent) {
|
||||||
if (theEvent.name=="canLoad") {
|
if (theEvent.name=="canLoad") {
|
||||||
var message = theEvent.message;
|
var message = theEvent.message;
|
||||||
console.log(message);
|
console.log(message);
|
||||||
if (message.name=="getSettings") {
|
if (message.name=="getSetting") {
|
||||||
console.log("Get Settings");
|
console.log("Get Setting");
|
||||||
var data = message.data;
|
theEvent.message = safari.extension.settings[message.setting];
|
||||||
theEvent.message = safari.extension.settings.bob;
|
} else if (message.name=="getSetting") {
|
||||||
|
console.log("Set Setting");
|
||||||
|
safari.extension.settings[message.setting] = message.data;
|
||||||
}
|
}
|
||||||
|
} else if (theEvent.name=="getPreferences") {
|
||||||
|
var preferences = {invisible: safari.extension.settings["invisible"], whitelist: FFWhitelist, blacklist: FFBlacklist}
|
||||||
|
safari.application.activeBrowserWindow.activeTab.page.dispatchMessage("preferences", preferences);
|
||||||
|
} else if (theEvent.name=="setInvisible") {
|
||||||
|
safari.extension.settings["invisible"] = theEvent.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
safari.application.addEventListener("message", handleMessage, false);
|
safari.application.addEventListener("message", handleMessage, false);
|
||||||
|
3
preferences.css
Normal file
3
preferences.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.flashfireTitle {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
82
preferences.html
Normal file
82
preferences.html
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>FlashFire Preferences</title>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var FFWhitelist = null;
|
||||||
|
function handleMessage(theEvent) {
|
||||||
|
if (theEvent.name=="preferences") {
|
||||||
|
console.log(theEvent.message);
|
||||||
|
document.getElementById("invisible").checked = theEvent.message.invisible;
|
||||||
|
FFWhitelist = theEvent.message.whitelist;
|
||||||
|
var whitelist = document.getElementById("whitelist");
|
||||||
|
for (i=0; i<FFWhitelist.length; i++) {
|
||||||
|
var item = document.createElement("option");
|
||||||
|
item.value = FFWhitelist[i];
|
||||||
|
item.innerHTML = FFWhitelist[i];
|
||||||
|
whitelist.appendChild(item);
|
||||||
|
}
|
||||||
|
document.getElementById("loading").style.display = "none";
|
||||||
|
document.getElementById("settings").style.display = "block";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setInvisible() {
|
||||||
|
safari.self.tab.dispatchMessage("setInvisible", document.getElementById("invisible").checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
function whitelistSelect() {
|
||||||
|
document.getElementById("whitelistRemoveButton").disabled = true;
|
||||||
|
var options = document.getElementById("whitelist").options;
|
||||||
|
for (i=0; i<options.length; i++) {
|
||||||
|
if (options[i].selected==true) {
|
||||||
|
document.getElementById("whitelistRemoveButton").disabled = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function whitelistRemove() {
|
||||||
|
var options = document.getElementById("whitelist").options;
|
||||||
|
for (i=0; i<options.length; i++) {
|
||||||
|
if (options[i].selected==true) {
|
||||||
|
console.log("Removing");
|
||||||
|
document.getElementById("whitelist").removeChild(options[i]);
|
||||||
|
document.getElementById("whitelistRemoveButton").disabled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function whitelistAdd() {
|
||||||
|
var site = document.getElementById("whitelistField").value;
|
||||||
|
if (site=="")
|
||||||
|
return;
|
||||||
|
var found = false;
|
||||||
|
for (i=0; i<FFWhitelist.length; i++) {
|
||||||
|
if (FFWhitelist[i]==site)
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
var item = document.createElement("option");
|
||||||
|
item.value = site;
|
||||||
|
item.innerHTML = site;
|
||||||
|
whitelist.appendChild(item);
|
||||||
|
}
|
||||||
|
document.getElementById("whitelistField").value = "";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
safari.self.tab.dispatchMessage("getPreferences");
|
||||||
|
safari.self.addEventListener("message", handleMessage, false);
|
||||||
|
</script>
|
||||||
|
<link rel="stylesheet" href="preferences.css" type="text/css" media="screen" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="settings" style="display: none">
|
||||||
|
<label for="invisible"><input type="checkbox" id="invisible" name="invisible" value="true" onclick="setInvisible();"> Load invisible flash automatically</label><br />
|
||||||
|
<br /><div class="flashfireTitle">Whitelist</div>
|
||||||
|
<select name="whitelist" id="whitelist" size="10" style="width: 400px" onchange="whitelistSelect()"></select><br />
|
||||||
|
<form onsubmit="return whitelistAdd();"><input type="text" id="whitelistField" size="54"><input type="submit" value="Add"><input type="button" id="whitelistRemoveButton" value="Remove" onclick="whitelistRemove()" disabled></form>
|
||||||
|
</div>
|
||||||
|
<div id="loading" style="text-align: center">Loading Preferences...</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user