Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merge in Marc Hoyois's latest changes

  • Loading branch information...
commit 94d31c01fd6c31b53a6c4c2124732c92ff618a66 2 parents 76044a9 + 17d40cf
Simone Manganelli authored
Showing with 3,263 additions and 3,375 deletions.
  1. BIN  .DS_Store
  2. BIN  ClickToPlugin.fr.safariextension/.DS_Store
  3. +232 −209 ClickToPlugin.fr.safariextension/ClickToPlugin.js
  4. +51 −51 ClickToPlugin.fr.safariextension/Info.plist
  5. +432 −432 ClickToPlugin.fr.safariextension/Settings.plist
  6. +46 −74 ClickToPlugin.fr.safariextension/functions.js
  7. +6 −5 ClickToPlugin.fr.safariextension/global.html
  8. +89 −173 ClickToPlugin.fr.safariextension/global.js
  9. +108 −35 ClickToPlugin.fr.safariextension/globalfunctions.js
  10. +8 −9 ClickToPlugin.fr.safariextension/killers/DailymotionKiller.js
  11. +3 −3 ClickToPlugin.fr.safariextension/killers/DivXKiller.js
  12. +70 −67 ClickToPlugin.fr.safariextension/killers/JWKiller.js
  13. +4 −4 ClickToPlugin.fr.safariextension/killers/QTKiller.js
  14. +3 −3 ClickToPlugin.fr.safariextension/killers/SLKiller.js
  15. +8 −9 ClickToPlugin.fr.safariextension/killers/VeohKiller.js
  16. +17 −44 ClickToPlugin.fr.safariextension/killers/VimeoKiller.js
  17. +4 −4 ClickToPlugin.fr.safariextension/killers/WMKiller.js
  18. +153 −165 ClickToPlugin.fr.safariextension/killers/YouTubeKiller.js
  19. +266 −270 ClickToPlugin.fr.safariextension/mediaPlayer.js
  20. BIN  ClickToPlugin.fr.safariextension/next.png
  21. BIN  ClickToPlugin.fr.safariextension/next_active.png
  22. BIN  ClickToPlugin.fr.safariextension/prev.png
  23. BIN  ClickToPlugin.fr.safariextension/prev_active.png
  24. +166 −165 ClickToPlugin.fr.safariextension/styles.css
  25. BIN  ClickToPlugin.safariextension/.DS_Store
  26. +232 −209 ClickToPlugin.safariextension/ClickToPlugin.js
  27. +416 −416 ClickToPlugin.safariextension/Settings.plist
  28. +46 −74 ClickToPlugin.safariextension/functions.js
  29. +6 −5 ClickToPlugin.safariextension/global.html
  30. +87 −171 ClickToPlugin.safariextension/global.js
  31. +108 −35 ClickToPlugin.safariextension/globalfunctions.js
  32. +8 −9 ClickToPlugin.safariextension/killers/DailymotionKiller.js
  33. +3 −3 ClickToPlugin.safariextension/killers/DivXKiller.js
  34. +70 −67 ClickToPlugin.safariextension/killers/JWKiller.js
  35. +4 −4 ClickToPlugin.safariextension/killers/QTKiller.js
  36. +3 −3 ClickToPlugin.safariextension/killers/SLKiller.js
  37. +8 −9 ClickToPlugin.safariextension/killers/VeohKiller.js
  38. +17 −44 ClickToPlugin.safariextension/killers/VimeoKiller.js
  39. +4 −4 ClickToPlugin.safariextension/killers/WMKiller.js
  40. +153 −165 ClickToPlugin.safariextension/killers/YouTubeKiller.js
  41. +266 −270 ClickToPlugin.safariextension/mediaPlayer.js
  42. BIN  ClickToPlugin.safariextension/next.png
  43. BIN  ClickToPlugin.safariextension/next_active.png
  44. BIN  ClickToPlugin.safariextension/prev.png
  45. BIN  ClickToPlugin.safariextension/prev_active.png
  46. +166 −165 ClickToPlugin.safariextension/styles.css
BIN  .DS_Store
View
Binary file not shown
BIN  ClickToPlugin.fr.safariextension/.DS_Store
View
Binary file not shown
441 ClickToPlugin.fr.safariextension/ClickToPlugin.js
View
@@ -1,45 +1,45 @@
-/*
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-NOTE TO SELF
-ALWAYS ALWAYS ALWAYS ALWAYS USE the 'var' keyword in 'for' loops!!!!!!!!!!
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-*/
-
-
/****************************
ClickToPlugin class definition
*****************************/
function ClickToPlugin() {
- this.blockedElements = new Array();// array containing the Flash HTML elements
+ this.blockedElements = new Array();// array containing the blocked HTML elements
this.placeholderElements = new Array();// array containing the corresponding placeholder elements
- this.mediaPlayers = new Array();// array containing the HTML5 media players
+ this.mediaPlayers = new Array();// array containing the HTML5 media players
+
+ /*
+ Each item in blockedElement will acquire 3 additional properties:
+ -> tag: 'embed', 'object', or 'applet'
+ -> plugin: the name of the plugin that would handle the element
+ -> info: an object; info.src is the source of the embedded content
+ */
this.settings = null;
this.instance = null;
this.numberOfBlockedElements = 0;
- this.numberOfUnblockedElements = 0;
- this.location = window.location.href;
+ this.numberOfUnblockedElements = 0;
+
+ var _this = this;
- var _this = this;
-
- this.respondToMessageTrampoline = function(event) {
+ this.respondToMessageTrampoline = function(event) {
_this.respondToMessage(event);
};
-
- this.handleEventTrampoline = function(event) {
- _this.handleEvent(event);
- };
+
+ this.handleEventTrampoline = function(event) {
+ _this.handleEvent(event);
+ };
- safari.self.addEventListener("message", this.respondToMessageTrampoline, false);
- document.addEventListener("beforeload", this.handleEventTrampoline, true);
+ safari.self.addEventListener("message", this.respondToMessageTrampoline, false);
+ document.addEventListener("beforeload", this.handleEventTrampoline, true);
+ // HTML applet elements fire no beforeload event
+ // bug filed: https://bugs.webkit.org/show_bug.cgi?id=44023
+ // Unsatisfactory workaround (Java will run anyway):
document.addEventListener("DOMContentLoaded", this.handleEventTrampoline, false);
- document.addEventListener("DOMNodeInserted", this.handleEventTrampoline, false);
- //document.addEventListener("DOMNodeInsertedIntoDocument", this.handleEventTrampoline, false);
+ document.addEventListener("DOMNodeInserted", this.handleEventTrampoline, false);
document.oncontextmenu = function(event) {
- safari.self.tab.setContextMenuEventUserInfo(event, {"location": _this.location, "blocked": _this.numberOfBlockedElements - _this.numberOfUnblockedElements});
+ safari.self.tab.setContextMenuEventUserInfo(event, {"location": window.location.href, "blocked": _this.numberOfBlockedElements - _this.numberOfUnblockedElements});
};
}
@@ -50,31 +50,41 @@ ClickToPlugin.prototype.clearAll = function(elementID) {
};
ClickToPlugin.prototype.respondToMessage = function(event) {
- if (event.name == "mediaData") {
- if(event.message.CTPInstance != this.instance) return; // ignore message from other CTP instances
- this.prepMedia(event.message);
- } else if (event.name == "loadContent") {
- var loadData = event.message.split(","); // [0] CTPInstance, [1] elementID, [2] message
- if (loadData[0] != this.instance) return; // ignore message from other CTP instances
- if (loadData[2] == "plugin") {
- this.loadPluginForElement(loadData[1]);
- } else if (loadData[2] == "video") {
- this.loadMediaForElement(loadData[1]);
- } else if (loadData[2] == "reloadPlugin") {
- this.loadInPlugin(loadData[1]);
- } else if (loadData[2] == "remove") {
- this.removeElement(loadData[1]);
- } else if (loadData[2] == "qtp") {
- this.launchInQuickTimePlayer(loadData[1]);
- } else if (loadData[2] == "show") {
- alert(document.HTMLToString(this.blockedElements[loadData[1]]));
- }
- } else if (event.name == "updateVolume") {
- this.setVolumeTo(event.message);
- } else if (event.name == "updateOpacity") {
- this.setOpacityTo(event.message);
- } else if(event.name == "loadAll") {
- this.loadAll();
+ switch(event.name) {
+ case "mediaData":
+ if(event.message.instance != this.instance) return; // ignore message from other CTP instances
+ this.prepMedia(event.message);
+ break;
+ case "loadContent":
+ var loadData = event.message.split(","); // [0] instance, [1] elementID, [2] message
+ if (loadData[0] != this.instance) return; // ignore message from other CTP instances
+ switch(loadData[2]) {
+ case "plugin":
+ this.loadPluginForElement(loadData[1]);
+ break;
+ case "remove":
+ this.removeElement(loadData[1]);
+ break;
+ case "reload":
+ this.reloadInPlugin(loadData[1]);
+ break;
+ case "qtp":
+ this.launchInQuickTimePlayer(loadData[1]);
+ break;
+ case "show":
+ alert(document.HTMLToString(this.blockedElements[loadData[1]]));
+ break;
+ }
+ break;
+ case "loadAll":
+ this.loadAll();
+ break;
+ case "updateVolume":
+ this.setVolumeTo(event.message);
+ break;
+ case "updateOpacity":
+ this.setOpacityTo(event.message);
+ break;
}
};
@@ -82,9 +92,8 @@ ClickToPlugin.prototype.respondToMessage = function(event) {
According to the W3C HTML5 spec, to activate a plugin,
-> an 'embed' element must have either the 'src' or the 'type' attribute with nonempty value
-> an 'object' element must have either the 'data' or the 'type' attribute with nonempty value.
-In the real world, however, (AS IS RECOMMANDED ON ADOBE'S WEBSITE, BY THE WAY!)
-one often finds an 'object' with neither 'data' nor 'type', with an 'embed' element
-as child with 'src' and/or 'type' attribute set.
+In the real world, however, one often finds an 'object' with neither 'data' nor 'type',
+with an 'embed' element as child with 'src' and/or 'type' attribute set.
*/
ClickToPlugin.prototype.handleEvent = function(event) {
@@ -102,21 +111,35 @@ ClickToPlugin.prototype.handleEvent = function(event) {
ClickToPlugin.prototype.handleDOMContentEvent = function(event) {
if(event.target.nodeType != 1 && event.target.nodeType != 9) return; // the node is not an HTML Element nor the document
const applets = event.target.getElementsByTagName("applet");
+ if(applets.length == 0) return;
+
// Convert NodeList to Array
var appletElements = new Array();
for(var i = 0; i < applets.length; i++) {
appletElements.push(applets[i]);
}
+ var tmpAnchor = document.createElement("a");
for(var i = 0; i < appletElements.length; i++) {
if(appletElements[i].allowedToLoad) continue;
appletElements[i].tag = "applet";
- appletElements[i].source = getSrcOf(appletElements[i]);
+ appletElements[i].info = new Object();
+
+ // Get source of applet
+ if(appletElements[i].code) {
+ tmpAnchor.href = appletElements[i].code;
+ appletElements[i].info.src = tmpAnchor.href;
+ } else if(appletElements[i].hasAttribute("archive")) {
+ tmpAnchor.href = appletElements[i].getAttribute("archive");
+ appletElements[i].info.src = tmpAnchor.href;
+ } else {
+ appletElements[i].info.src = "";
+ }
- var pluginName = safari.self.tab.canLoad(event, {"src": appletElements[i].source, "type": "application/x-java-applet", "classid": "", "params": "", "location": this.location, "width": appletElements[i].offsetWidth, "height": appletElements[i].offsetHeight, "otherInfo": null});
+ var pluginName = safari.self.tab.canLoad(event, {"src": appletElements[i].info.src, "type": "application/x-java-applet", "location": window.location.href, "width": appletElements[i].offsetWidth, "height": appletElements[i].offsetHeight});
if(!pluginName) continue; // whitelisted
- appletElements[i].plugin = pluginName;
+ appletElements[i].plugin = "Java";
if(this.settings == null) {
this.settings = safari.self.tab.canLoad(event, "getSettings");
@@ -125,15 +148,21 @@ ClickToPlugin.prototype.handleDOMContentEvent = function(event) {
this.instance = safari.self.tab.canLoad(event, "getInstance");
}
var elementID = this.numberOfBlockedElements++;
- this.processBlockedElement(appletElements[i], elementID); // this removes appletElements[0] from the document
+ // BEGIN DEBUG
+ if(this.settings["debug"]) {
+ if(!confirm("ClickToPlugin is about to block embedded content " + this.instance + "." + elementID + ":\n\n" + document.HTMLToString(element))) return;
+ }
+ // END DEBUG
+
+ this.processBlockedElement(appletElements[i], elementID);
}
};
ClickToPlugin.prototype.handleBeforeLoadEvent = function(event) {
- const element = event.target;
-
+ const element = event.target;
+
// deal with sIFR script first
- if(element instanceof HTMLScriptElement && element.getAttribute("src").indexOf("sifr.js") != (-1)) {
+ if(element instanceof HTMLScriptElement && element.src.indexOf("sifr.js") != (-1)) {
var sIFRData = safari.self.tab.canLoad(event, "sIFR");
if(!sIFRData.canLoad) {
// BEGIN DEBUG
@@ -151,7 +180,8 @@ ClickToPlugin.prototype.handleBeforeLoadEvent = function(event) {
// the beforeload event is fired again but this time the
// flash element must not be blocked
if (element.allowedToLoad) return;
- if (element instanceof HTMLEmbedElement) {
+
+ if (element instanceof HTMLEmbedElement) {
element.tag = "embed";
} else if (element instanceof HTMLObjectElement) {
element.tag = "object";
@@ -159,29 +189,20 @@ ClickToPlugin.prototype.handleBeforeLoadEvent = function(event) {
return;
}
+ element.info = getInfo(element, event.url);
+
+ var pluginName = safari.self.tab.canLoad(event, {"src": element.info.src, "type": getTypeOf(element), "classid": element.getAttribute("classid"), "location": window.location.href, "width": element.offsetWidth, "height": element.offsetHeight, "launchInQTP": element.info.target == "quicktimeplayer" ? element.info.href : null});
+ if(!pluginName) return; // whitelisted
+
// Load the user settings
if(this.settings == null) {
this.settings = safari.self.tab.canLoad(event, "getSettings");
}
- // Give an address to this CTP instance to receive messages
- if(this.instance == null) {
- this.instance = safari.self.tab.canLoad(event, "getInstance");
- }
-
- element.otherInfo = new Object();
- element.source = getSrcOf(element);
-
- var pluginName = safari.self.tab.canLoad(event, {"src": element.source, "type": getTypeOf(element), "classid": element.getAttribute("classid"), "params": this.settings["useH264"] ? getParamsOf(element) : "", "location": this.location, "width": element.offsetWidth, "height": element.offsetHeight, "otherInfo": element.otherInfo});
- if(!pluginName) return; // whitelisted
- //alert(pluginName);
-
-
-
- // if useh264...
+ // if useh264...
// Deal with sIFR Flash
- if (element.className == "sIFR-flash" || element.getAttribute("sifr")) {
+ if (element.className == "sIFR-flash" || element.hasAttribute("sifr")) {
if (this.settings["sifrReplacement"] == "autoload") {
// BEGIN DEBUG
if(this.settings["debug"]) {
@@ -193,13 +214,17 @@ ClickToPlugin.prototype.handleBeforeLoadEvent = function(event) {
}
// At this point we know we have to block 'element' from loading
+ var elementID = this.numberOfBlockedElements++;
element.plugin = pluginName;
- var elementID = this.numberOfBlockedElements++;
+
+ // Give an address to this CTP instance to receive messages
+ if(this.instance == null) {
+ this.instance = safari.self.tab.canLoad(event, "getInstance");
+ }
// BEGIN DEBUG
if(this.settings["debug"]) {
- if(!confirm(window.location.href + "\n" + window.top.location.href + "\nClickToPlugin is about to block embedded content " + this.instance + "." + elementID + ":\n\n" + document.HTMLToString(element))) return;
- //alert(element.source + "\n -- \n" + event.url);
+ if(!confirm("ClickToPlugin is about to block embedded content " + this.instance + "." + elementID + ":\n\n" + document.HTMLToString(element))) return;
}
// END DEBUG
@@ -209,38 +234,37 @@ ClickToPlugin.prototype.handleBeforeLoadEvent = function(event) {
ClickToPlugin.prototype.prepMedia = function(mediaData) {
if(mediaData.playlist.length == 0 || !mediaData.playlist[0].mediaURL) return;
- if(!this.mediaPlayers[mediaData.elementID]) {
- this.mediaPlayers[mediaData.elementID] = new mediaPlayer(mediaData.isAudio ? "audio" : "video");
- }
- if(mediaData.loadAfter) { // just adding stuff to the playlist
- // BEGIN DEBUG
- if(this.settings["debug"]) {
- if(!confirm("Preparing to add " + mediaData.playlist.length + " tracks to the playlist for element " + this.instance +"."+ mediaData.elementID)) return;
- }
- // END DEBUG
- this.mediaPlayers[mediaData.elementID].playlistLength -= mediaData.missed;
- this.mediaPlayers[mediaData.elementID].addToPlaylist(mediaData.playlist);
- return;
- }
- // BEGIN DEBUG
- if(this.settings["debug"]) {
- var showPlaylist = "(" + mediaData.playlist.length + " track" + (mediaData.playlist.length > 1 ? "s" : "") + ")";
+ if(!this.mediaPlayers[mediaData.elementID]) {
+ this.mediaPlayers[mediaData.elementID] = new mediaPlayer(mediaData.isAudio ? "audio" : "video");
+ }
+ if(mediaData.loadAfter) { // just adding stuff to the playlist
+ // BEGIN DEBUG
+ if(this.settings["debug"]) {
+ if(!confirm("Preparing to add " + mediaData.playlist.length + " tracks to the playlist for element " + this.instance +"."+ mediaData.elementID)) return;
+ }
+ // END DEBUG
+ this.mediaPlayers[mediaData.elementID].playlistLength -= mediaData.missed;
+ this.mediaPlayers[mediaData.elementID].addToPlaylist(mediaData.playlist);
+ return;
+ }
+ // BEGIN DEBUG
+ if(this.settings["debug"]) {
+ var showPlaylist = "(" + mediaData.playlist.length + " track" + (mediaData.playlist.length > 1 ? "s" : "");
+ if(mediaData.playlistLength) showPlaylist += ", expecting " + mediaData.playlistLength;
+ showPlaylist += ")";
for (var i = 0; i < mediaData.playlist.length; i++) {
- showPlaylist += "\n[" + (i + 1) + "] (" + mediaData.playlist[i].mediaType + ")" + (mediaData.playlist[i].mediaType == "video" ? ("\nposterURL: " + mediaData.playlist[i].posterURL) : "") + "\nmediaURL: " + mediaData.playlist[i].mediaURL + "\n";
+ showPlaylist += "\n[" + (i + 1) + "] (" + mediaData.playlist[i].mediaType + ")" + "\nposterURL: " + mediaData.playlist[i].posterURL + "\nmediaURL: " + mediaData.playlist[i].mediaURL + "\n";
}
if(!confirm("Preparing media for element " + this.instance +"."+ mediaData.elementID +
":\n\nbadgeLabel: " + mediaData.badgeLabel + "\n\nPLAYLIST " + showPlaylist)) return;
}
// END DEBUG
-
- // do it backward just in case a loadAfter came first
- // can happen for embedded playlists
-
- this.mediaPlayers[mediaData.elementID].addToPlaylist(mediaData.playlist, true);
- this.mediaPlayers[mediaData.elementID].playlistLength = mediaData.playlistLength ? mediaData.playlistLength : mediaData.playlist.length;
- this.mediaPlayers[mediaData.elementID].startTrack = mediaData.startTrack ? mediaData.startTrack : 0;
-
- this.mediaPlayers[mediaData.elementID].usePlaylistControls = this.settings["usePlaylists"] && !mediaData.noPlaylistControls && this.mediaPlayers[mediaData.elementID].playlistLength > 1;
+
+ this.mediaPlayers[mediaData.elementID].addToPlaylist(mediaData.playlist, true);
+ this.mediaPlayers[mediaData.elementID].playlistLength = mediaData.playlistLength ? mediaData.playlistLength : mediaData.playlist.length;
+ this.mediaPlayers[mediaData.elementID].startTrack = mediaData.startTrack ? mediaData.startTrack : 0;
+
+ this.mediaPlayers[mediaData.elementID].usePlaylistControls = this.settings["usePlaylists"] && !mediaData.noPlaylistControls && this.mediaPlayers[mediaData.elementID].playlistLength > 1;
// Check if we should load video at once
if(this.settings["H264autoload"]) {
@@ -249,17 +273,17 @@ ClickToPlugin.prototype.prepMedia = function(mediaData) {
}
var badgeLabel = mediaData.badgeLabel;
if(!badgeLabel) badgeLabel = "Video";
-
+
this.displayBadge(badgeLabel, mediaData.elementID);
};
ClickToPlugin.prototype.loadPluginForElement = function(elementID) {
var placeholderElement = this.placeholderElements[elementID];
- var element = this.blockedElements[elementID];
- element.allowedToLoad = true;
+ var element = this.blockedElements[elementID];
+ element.allowedToLoad = true;
if(placeholderElement.parentNode) {
placeholderElement.parentNode.replaceChild(element, placeholderElement);
- this.numberOfUnblockedElements++;
+ this.numberOfUnblockedElements++;
this.clearAll(elementID);
}
};
@@ -271,14 +295,14 @@ ClickToPlugin.prototype.loadAll = function() {
this.loadPluginForElement(i);
}
}
- this.numberOfUnblockedElements = this.numberOfBlockedElements;
+ this.numberOfUnblockedElements = this.numberOfBlockedElements;
};
-ClickToPlugin.prototype.loadInPlugin = function(elementID) {
+ClickToPlugin.prototype.reloadInPlugin = function(elementID) {
var containerElement = this.mediaPlayers[elementID].containerElement;
- var element = this.blockedElements[elementID];
- element.allowedToLoad = true;
- containerElement.parentNode.replaceChild(element, containerElement);
+ var element = this.blockedElements[elementID];
+ element.allowedToLoad = true;
+ containerElement.parentNode.replaceChild(element, containerElement);
this.clearAll(elementID);
};
@@ -286,56 +310,54 @@ ClickToPlugin.prototype.loadMediaForElement = function(elementID) {
var placeholderElement = this.placeholderElements[elementID];
var contextInfo = {
- "CTPInstance": this.instance,
+ "instance": this.instance,
"elementID": elementID,
"isH264": true,
"plugin": this.blockedElements[elementID].plugin
- //"blocked": this.numberOfBlockedElements - this.numberOfUnblockedElements
+ //"blocked": this.numberOfBlockedElements - this.numberOfUnblockedElements
};
- // Initialize player
- var w = parseInt(placeholderElement.style.width.replace("px",""));
- var h = parseInt(placeholderElement.style.height.replace("px",""));
- this.mediaPlayers[elementID].initialize(this.settings["H264behavior"], w, h, this.settings["volume"], contextInfo);
- //mediaElement.allowedToLoad = true; // not used for now
-
- // Load first track
- this.mediaPlayers[elementID].loadTrack(0);
+ // Initialize player
+ var w = parseInt(placeholderElement.style.width.replace("px",""));
+ var h = parseInt(placeholderElement.style.height.replace("px",""));
+ this.mediaPlayers[elementID].initialize(this.settings["H264behavior"], w, h, this.settings["volume"], contextInfo);
+ // mediaElement.allowedToLoad = true; // not used
- // Replace placeholder
- placeholderElement.parentNode.replaceChild(this.mediaPlayers[elementID].containerElement, placeholderElement);
- this.numberOfUnblockedElements++;
+ // Replace placeholder and load first track
+ placeholderElement.parentNode.replaceChild(this.mediaPlayers[elementID].containerElement, placeholderElement);
+ this.mediaPlayers[elementID].loadTrack(0);
+ this.numberOfUnblockedElements++;
this.placeholderElements[elementID] = null;
};
ClickToPlugin.prototype.launchInQuickTimePlayer = function(elementID) {
- var track = this.mediaPlayers[elementID].currentTrack;
- var element = null;
- if(track == null) {
- track = 0;
- element = this.placeholderElements[elementID];
- } else {
- element = this.mediaPlayers[elementID].containerElement;
- }
+ var track = this.mediaPlayers[elementID].currentTrack;
+ var element = null;
+ if(track == null) {
+ track = 0;
+ element = this.placeholderElements[elementID];
+ } else {
+ element = this.mediaPlayers[elementID].containerElement;
+ }
var mediaURL = this.mediaPlayers[elementID].playlist[track].mediaURL;
- var QTObject = document.createElement("embed");
- QTObject.allowedToLoad = true;
- QTObject.className = "CTFQTObject";
- QTObject.setAttribute("type", "video/quicktime");
- QTObject.setAttribute("width", "0");
- QTObject.setAttribute("height", "0");
- // need an external URL for source, since QT plugin doesn't accept safari-extension:// protocol
- // Apple has a small 1px image for this exact purpose
- QTObject.setAttribute("src", "http://images.apple.com/apple-events/includes/qtbutton.mov");
- QTObject.setAttribute("href", mediaURL);
- QTObject.setAttribute("target", "quicktimeplayer");
- QTObject.setAttribute("autohref", "true");
- QTObject.setAttribute("controller", "false");
- //QTObject.setAttribute("postdomevents", "true");
- element.appendChild(QTObject);
- // There doesn't seem to exist an appropriate event, so we just wait a bit...
- setTimeout(function() {element.removeChild(QTObject);}, 100);
+ var QTObject = document.createElement("embed");
+ QTObject.allowedToLoad = true;
+ QTObject.className = "CTFQTObject";
+ QTObject.setAttribute("type", "video/quicktime");
+ QTObject.setAttribute("width", "0");
+ QTObject.setAttribute("height", "0");
+ // need an external URL for source, since QT plugin doesn't accept safari-extension:// protocol
+ // Apple has a small 1px image for this exact purpose
+ QTObject.setAttribute("src", "http://images.apple.com/apple-events/includes/qtbutton.mov");
+ QTObject.setAttribute("href", mediaURL);
+ QTObject.setAttribute("target", "quicktimeplayer");
+ QTObject.setAttribute("autohref", "true");
+ QTObject.setAttribute("controller", "false");
+ // QTObject.setAttribute("postdomevents", "true");
+ element.appendChild(QTObject);
+ // There doesn't seem to exist an appropriate event, so we just wait a bit...
+ setTimeout(function() {element.removeChild(QTObject);}, 100);
};
ClickToPlugin.prototype.setVolumeTo = function(volume) {
@@ -356,7 +378,7 @@ ClickToPlugin.prototype.removeElement = function(elementID) {
element = element.parentNode;
}
element.parentNode.removeChild(element);
- this.numberOfUnblockedElements++;
+ this.numberOfUnblockedElements++;
this.clearAll(elementID);
};
@@ -376,11 +398,11 @@ ClickToPlugin.prototype.displayBadge = function(badgeLabel, elementID) {
this.placeholderElements[elementID].firstChild.firstChild.firstChild.firstChild.className = "logoContainer hidden";
this.placeholderElements[elementID].firstChild.firstChild.firstChild.firstChild.childNodes[1].className = "logo tmp";
- this.unhideLogo(elementID);
+ this.unhideLogo(elementID, 0);
};
// NOTE: this function should never be called directly (use displayBadge instead)
-ClickToPlugin.prototype.unhideLogo = function(elementID) {
+ClickToPlugin.prototype.unhideLogo = function(elementID, i) {
var logoContainer = this.placeholderElements[elementID].firstChild.firstChild.firstChild.firstChild;
var w0 = this.placeholderElements[elementID].offsetWidth;
var h0 = this.placeholderElements[elementID].offsetHeight;
@@ -390,10 +412,11 @@ ClickToPlugin.prototype.unhideLogo = function(elementID) {
var h2 = logoContainer.childNodes[1].offsetHeight;
if(w2 == 0 || h2 == 0 || w1 == 0 || h1 == 0 || w0 == 0 || h0 == 0) {
+ if(i > 9) return;
// 2 options: leave the logo hidden (no big deal, and rarely happens),
- // or run unhideLogo again later (this might cause unexpected results due to asynchronicity)
+ // or run unhideLogo again later <- THIS
var _this = this;
- setTimeout(function() {_this.unhideLogo(elementID);}, 100); // there's no hurry here
+ setTimeout(function() {_this.unhideLogo(elementID, ++i);}, 100); // there's no hurry here
return;
}
@@ -418,22 +441,22 @@ ClickToPlugin.prototype.unhideLogo = function(elementID) {
};
ClickToPlugin.prototype.clickPlaceholder = function(elementID) {
- if (this.mediaPlayers[elementID] && this.mediaPlayers[elementID].startTrack != null) {
- this.loadMediaForElement(elementID);
- } else {
+ if (this.mediaPlayers[elementID] && this.mediaPlayers[elementID].startTrack != null) {
+ this.loadMediaForElement(elementID);
+ } else {
this.loadPluginForElement(elementID);
- }
+ }
};
ClickToPlugin.prototype.processBlockedElement = function(element, elementID) {
// Creating the placeholder element
- var placeholderElement = document.createElement("div");
- placeholderElement.style.width = element.offsetWidth + "px";
- placeholderElement.style.height = element.offsetHeight + "px";
- placeholderElement.style.opacity = this.settings["opacity"];
+ var placeholderElement = document.createElement("div");
+ placeholderElement.style.width = element.offsetWidth + "px";
+ placeholderElement.style.height = element.offsetHeight + "px";
+ placeholderElement.style.opacity = this.settings["opacity"];
- placeholderElement.className = "clickToFlashPlaceholder";
+ placeholderElement.className = "clickToFlashPlaceholder";
// Replacing element by placeholderElement
if (element.parentNode) {
@@ -445,54 +468,54 @@ ClickToPlugin.prototype.processBlockedElement = function(element, elementID) {
alert("Ignoring duplicate element " + this.instance + "." + elementID + ".");
}
// END DEBUG
- this.numberOfUnblockedElements++;
+ this.numberOfUnblockedElements++;
return;
}
- var _this = this;
- placeholderElement.onclick = function(event){_this.clickPlaceholder(elementID);};
- placeholderElement.oncontextmenu = function(event) {
- var contextInfo = {
- "CTPInstance": _this.instance,
+ var _this = this;
+ placeholderElement.onclick = function(event){_this.clickPlaceholder(elementID);};
+ placeholderElement.oncontextmenu = function(event) {
+ var contextInfo = {
+ "instance": _this.instance,
"elementID": elementID,
- "src": element.source,
+ "src": element.info.src,
"plugin": element.plugin,
- "blocked": _this.numberOfBlockedElements - _this.numberOfUnblockedElements
+ //"blocked": _this.numberOfBlockedElements - _this.numberOfUnblockedElements
};
if (_this.mediaPlayers[elementID] && _this.mediaPlayers[elementID].startTrack != null) {
- contextInfo.hasH264 = true;
+ contextInfo.hasH264 = true;
_this.mediaPlayers[elementID].setContextInfo(event, contextInfo);
} else {
- contextInfo.hasH264 = false;
- safari.self.tab.setContextMenuEventUserInfo(event, contextInfo);
- event.stopPropagation();
+ contextInfo.hasH264 = false;
+ safari.self.tab.setContextMenuEventUserInfo(event, contextInfo);
+ event.stopPropagation();
}
- };
+ };
// Building the placeholder
- var container = document.createElement("div");
- container.className = "clickToFlashPlaceholderContainer";
- placeholderElement.appendChild(container);
-
- var verticalPositionElement = document.createElement("div");
- verticalPositionElement.className = "logoVerticalPosition";
- container.appendChild(verticalPositionElement);
-
- var horizontalPositionElement = document.createElement("div");
- horizontalPositionElement.className = "logoHorizontalPosition";
- verticalPositionElement.appendChild(horizontalPositionElement);
-
- var logoContainer = document.createElement("div");
- logoContainer.className = "logoContainer nodisplay"; // keep the logo hidden at first
- horizontalPositionElement.appendChild(logoContainer);
-
- var logoElement = document.createElement("div");
- logoElement.className = "logo";
- logoContainer.appendChild(logoElement);
-
- var logoInsetElement = document.createElement("div");
- logoInsetElement.className = "logo inset";
- logoContainer.appendChild(logoInsetElement);
+ var container = document.createElement("div");
+ container.className = "clickToFlashPlaceholderContainer";
+ placeholderElement.appendChild(container);
+
+ var verticalPositionElement = document.createElement("div");
+ verticalPositionElement.className = "logoVerticalPosition";
+ container.appendChild(verticalPositionElement);
+
+ var horizontalPositionElement = document.createElement("div");
+ horizontalPositionElement.className = "logoHorizontalPosition";
+ verticalPositionElement.appendChild(horizontalPositionElement);
+
+ var logoContainer = document.createElement("div");
+ logoContainer.className = "logoContainer nodisplay"; // keep the logo hidden at first
+ horizontalPositionElement.appendChild(logoContainer);
+
+ var logoElement = document.createElement("div");
+ logoElement.className = "logo";
+ logoContainer.appendChild(logoElement);
+
+ var logoInsetElement = document.createElement("div");
+ logoInsetElement.className = "logo inset";
+ logoContainer.appendChild(logoInsetElement);
// Filling the main arrays
this.blockedElements[elementID] = element;
@@ -503,14 +526,14 @@ ClickToPlugin.prototype.processBlockedElement = function(element, elementID) {
if(this.settings["useH264"]) {
if(!this.directKill(elementID)) {
var elementData = {
+ "instance": this.instance,
+ "elementID": elementID,
"plugin": element.plugin,
- "src": element.source,
- "presrc": element.presource, // TEMP!!
+ "src": element.info.href ? element.info.href : element.info.src,
+ "presrc": element.info.href ? element.info.src : "",
+ "image": element.info.image,
"params": getParamsOf(element),
- "elementID": elementID,
- "CTPInstance": this.instance,
- "location": this.location,
- "image": element.image
+ "location": window.location.href
};
safari.self.tab.dispatchMessage("killPlugin", elementData);
}
@@ -549,7 +572,7 @@ ClickToPlugin.prototype.directKill = function(elementID) {
var mediaData = {
"elementID": elementID,
"playlist": [{"mediaType": mediaType, "posterURL": mediaElements[0].getAttribute("poster"), "mediaURL": mediaURL}],
- "badgeLabel": "Video"
+ "badgeLabel": mediaType == "audio" ? "Audio" : "Video"
};
this.prepMedia(mediaData);
return true;
102 ClickToPlugin.fr.safariextension/Info.plist
View
@@ -2,56 +2,56 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
- <key>Author</key>
- <string>Marc Hoyois</string>
- <key>CFBundleDisplayName</key>
- <string>ClickToPlugin</string>
- <key>CFBundleIdentifier</key>
- <string>com.hoyois.safari.clicktoplugin.fr</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundleShortVersionString</key>
- <string>1.3.3</string>
- <key>CFBundleVersion</key>
- <string>1.3.3</string>
- <key>Chrome</key>
- <dict>
- <key>Global Page</key>
- <string>global.html</string>
- </dict>
- <key>Content</key>
- <dict>
- <key>Scripts</key>
- <dict>
- <key>Start</key>
- <array>
- <string>functions.js</string>
- <string>mediaPlayer.js</string>
- <string>ClickToPlugin.js</string>
- </array>
- </dict>
- <key>Stylesheets</key>
- <array>
- <string>styles.css</string>
- </array>
- </dict>
- <key>Description</key>
- <string>Empêche l'exécution automatique des plugins</string>
- <key>ExtensionInfoDictionaryVersion</key>
- <string>1.0</string>
- <key>Permissions</key>
- <dict>
- <key>Website Access</key>
- <dict>
- <key>Include Secure Pages</key>
- <true/>
- <key>Level</key>
- <string>All</string>
- </dict>
- </dict>
- <key>Update Manifest URL</key>
- <string>http://hoyois.github.com/safariextensions/updates.plist</string>
- <key>Website</key>
- <string>http://hoyois.github.com/safariextensions/clicktoplugin/</string>
+ <key>Author</key>
+ <string>Marc Hoyois</string>
+ <key>CFBundleDisplayName</key>
+ <string>ClickToPlugin</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.hoyois.safari.clicktoplugin.fr</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.3.3</string>
+ <key>CFBundleVersion</key>
+ <string>1.3.3</string>
+ <key>Chrome</key>
+ <dict>
+ <key>Global Page</key>
+ <string>global.html</string>
+ </dict>
+ <key>Content</key>
+ <dict>
+ <key>Scripts</key>
+ <dict>
+ <key>Start</key>
+ <array>
+ <string>functions.js</string>
+ <string>mediaPlayer.js</string>
+ <string>ClickToPlugin.js</string>
+ </array>
+ </dict>
+ <key>Stylesheets</key>
+ <array>
+ <string>styles.css</string>
+ </array>
+ </dict>
+ <key>Description</key>
+ <string>Empêche l'exécution automatique des plugins</string>
+ <key>ExtensionInfoDictionaryVersion</key>
+ <string>1.0</string>
+ <key>Permissions</key>
+ <dict>
+ <key>Website Access</key>
+ <dict>
+ <key>Include Secure Pages</key>
+ <true/>
+ <key>Level</key>
+ <string>All</string>
+ </dict>
+ </dict>
+ <key>Update Manifest URL</key>
+ <string>http://hoyois.github.com/safariextensions/updates.plist</string>
+ <key>Website</key>
+ <string>http://hoyois.github.com/safariextensions/clicktoplugin/</string>
</dict>
</plist>
864 ClickToPlugin.fr.safariextension/Settings.plist
View
@@ -2,437 +2,437 @@
<!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>Title</key>
- <string>Options MIME</string>
- <key>Type</key>
- <string>Group</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <string>blockAll</string>
- <key>Key</key>
- <string>block</string>
- <key>Title</key>
- <string>Bloquer</string>
- <key>Titles</key>
- <array>
- <string>tous les types MIME</string>
- <string>tous sauf ceux de la liste verte</string>
- <string>seulement ceux de la liste rouge</string>
- </array>
- <key>Type</key>
- <string>RadioButtons</string>
- <key>Values</key>
- <array>
- <string>blockAll</string>
- <string>useGreenlist</string>
- <string>useRedlist</string>
- </array>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <string></string>
- <key>Key</key>
- <string>greenlist</string>
- <key>Title</key>
- <string>Liste verte</string>
- <key>Type</key>
- <string>TextField</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <string>flash, futuresplash, silverlight</string>
- <key>Key</key>
- <string>redlist</string>
- <key>Title</key>
- <string>Liste rouge</string>
- <key>Type</key>
- <string>TextField</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <false/>
- <key>Key</key>
- <string>allowQT</string>
- <key>Title</key>
- <string>Autoriser le plugin QuickTime                          </string>
- <key>Type</key>
- <string>CheckBox</string>
- </dict>
- <dict>
- <key>Title</key>
- <string>Options vidéo</string>
- <key>Type</key>
- <string>Group</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <true/>
- <key>Key</key>
- <string>useH264</string>
- <key>Title</key>
- <string>Rechercher des vidéos pour remplacer             </string>
- <key>Type</key>
- <string>CheckBox</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <true/>
- <key>Key</key>
- <string>replaceFlash</string>
- <key>Title</key>
- <string>Flash                                             </string>
- <key>Type</key>
- <string>CheckBox</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <true/>
- <key>Key</key>
- <string>replaceSL</string>
- <key>Title</key>
- <string>Silverlight                                      </string>
- <key>Type</key>
- <string>CheckBox</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <true/>
- <key>Key</key>
- <string>replaceQT</string>
- <key>Title</key>
- <string>QuickTime                                    </string>
- <key>Type</key>
- <string>CheckBox</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <true/>
- <key>Key</key>
- <string>replaceWM</string>
- <key>Title</key>
- <string>Windows Media                             </string>
- <key>Type</key>
- <string>CheckBox</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <true/>
- <key>Key</key>
- <string>usePlaylists</string>
- <key>Title</key>
- <string>Utiliser les listes de lecture                               </string>
- <key>Titles</key>
- <array>
- <string>Ne pas utiliser</string>
- <string>N'utiliser qu'en dernier recours</string>
- <string>Utiliser sans restrictions</string>
- </array>
- <key>Type</key>
- <string>CheckBox</string>
- <key>Values</key>
- <array>
- <real>1</real>
- <real>2</real>
- <real>3</real>
- </array>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <false/>
- <key>Key</key>
- <string>H264autoload</string>
- <key>Title</key>
- <string>Effectuer les remplacements automatiquement</string>
- <key>Type</key>
- <string>CheckBox</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <string>autoplay</string>
- <key>Key</key>
- <string>H264behavior</string>
- <key>Title</key>
- <string>Une fois effectués</string>
- <key>Titles</key>
- <array>
- <string>Attendre avant de télécharger</string>
- <string>Commencer le téléchargement</string>
- <string>Commencer la lecture automatiquement</string>
- </array>
- <key>Type</key>
- <string>PopUpButton</string>
- <key>Values</key>
- <array>
- <string>none</string>
- <string>buffer</string>
- <string>autoplay</string>
- </array>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <real>2</real>
- <key>Key</key>
- <string>QTbehavior</string>
- <key>Title</key>
- <string>Codecs non natifs</string>
- <key>Titles</key>
- <array>
- <string>Ne pas utiliser</string>
- <string>N'utiliser qu'en dernier recours</string>
- <string>Utiliser sans restrictions</string>
- </array>
- <key>Type</key>
- <string>PopUpButton</string>
- <key>Values</key>
- <array>
- <real>1</real>
- <real>2</real>
- <real>3</real>
- </array>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <real>3</real>
- <key>Key</key>
- <string>maxresolution</string>
- <key>Title</key>
- <string>Résolution max</string>
- <key>Titles</key>
- <array>
- <string>480p</string>
- <string>720p</string>
- <string>1080p</string>
- <string>4K</string>
- </array>
- <key>Type</key>
- <string>PopUpButton</string>
- <key>Values</key>
- <array>
- <real>1</real>
- <real>2</real>
- <real>3</real>
- <real>4</real>
- </array>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <real>0.5</real>
- <key>Key</key>
- <string>volume</string>
- <key>MaximumValue</key>
- <real>1</real>
- <key>StepValue</key>
- <real>0.01</real>
- <key>Title</key>
- <string>Volume sonore</string>
- <key>Type</key>
- <string>Slider</string>
- </dict>
- <dict>
- <key>Title</key>
- <string>Liste blanche</string>
- <key>Type</key>
- <string>Group</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <false/>
- <key>Key</key>
- <string>uselocWhitelist</string>
- <key>Title</key>
- <string>Autoriser les plugins si l'adresse de la page     </string>
- <key>Type</key>
- <string>CheckBox</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <string>www.example.com, www.example2.com</string>
- <key>Key</key>
- <string>locwhitelist</string>
- <key>Title</key>
- <string>contient</string>
- <key>Type</key>
- <string>TextField</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <string></string>
- <key>Key</key>
- <string>locblacklist</string>
- <key>Title</key>
- <string>ne contient pas</string>
- <key>Type</key>
- <string>TextField</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <false/>
- <key>Key</key>
- <string>usesrcWhitelist</string>
- <key>Title</key>
- <string>Autoriser les plugins si l'adresse de l'objet       </string>
- <key>Type</key>
- <string>CheckBox</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <string></string>
- <key>Key</key>
- <string>srcwhitelist</string>
- <key>Title</key>
- <string>contient</string>
- <key>Type</key>
- <string>TextField</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <string></string>
- <key>Key</key>
- <string>srcblacklist</string>
- <key>Title</key>
- <string>ne contient pas</string>
- <key>Type</key>
- <string>TextField</string>
- </dict>
- <dict>
- <key>Title</key>
- <string>Éléments invisibles</string>
- <key>Type</key>
- <string>Group</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <false/>
- <key>Key</key>
- <string>loadInvisible</string>
- <key>Title</key>
- <string>Autoriser les éléments aux dimensions            </string>
- <key>Type</key>
- <string>CheckBox</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <real>1</real>
- <key>Key</key>
- <string>maxinvdim</string>
- <key>Title</key>
- <string>n'excédant pas</string>
- <key>Titles</key>
- <array>
- <string>1 x 1 px</string>
- <string>2 x 2 px</string>
- <string>4 x 4 px</string>
- <string>8 x 8 px</string>
- </array>
- <key>Type</key>
- <string>PopUpButton</string>
- <key>Values</key>
- <array>
- <real>1</real>
- <real>2</real>
- <real>4</real>
- <real>8</real>
- </array>
- </dict>
- <dict>
- <key>Title</key>
- <string>Menu contextuel</string>
- <key>Type</key>
- <string>Group</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <false/>
- <key>Key</key>
- <string>useWLcontext</string>
- <key>Title</key>
- <string>Ajouter à la liste blanche                                  </string>
- <key>Type</key>
- <string>CheckBox</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <false/>
- <key>Key</key>
- <string>useLAcontext</string>
- <key>Title</key>
- <string>Débloquer tous les plugins                               </string>
- <key>Type</key>
- <string>CheckBox</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <false/>
- <key>Key</key>
- <string>useVScontext</string>
- <key>Title</key>
- <string>Voir la vidéo sur le site                                     </string>
- <key>Type</key>
- <string>CheckBox</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <false/>
- <key>Key</key>
- <string>useQTcontext</string>
- <key>Title</key>
- <string>Ouvrir dans QuickTime Player                           </string>
- <key>Type</key>
- <string>CheckBox</string>
- </dict>
- <dict>
- <key>Type</key>
- <string>Separator</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <string>textonly</string>
- <key>Key</key>
- <string>sifrReplacement</string>
- <key>Title</key>
- <string>Texte sIFR</string>
- <key>Titles</key>
- <array>
- <string>N'afficher que le texte</string>
- <string>Considérer comme Flash</string>
- <string>Autoriser</string>
- </array>
- <key>Type</key>
- <string>PopUpButton</string>
- <key>Values</key>
- <array>
- <string>textonly</string>
- <string>normal</string>
- <string>autoload</string>
- </array>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <real>1</real>
- <key>Key</key>
- <string>opacity</string>
- <key>MaximumValue</key>
- <real>1</real>
- <key>Secure</key>
- <false/>
- <key>StepValue</key>
- <real>0.01</real>
- <key>Title</key>
- <string>Opacité</string>
- <key>Type</key>
- <string>Slider</string>
- </dict>
- <dict>
- <key>DefaultValue</key>
- <string></string>
- <key>Key</key>
- <string>debug</string>
- <key>Title</key>
- <string>Activer le mode de débogage                           </string>
- <key>Type</key>
- <string>Hidden</string>
- </dict>
+ <dict>
+ <key>Title</key>
+ <string>Options MIME</string>
+ <key>Type</key>
+ <string>Group</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <string>blockAll</string>
+ <key>Key</key>
+ <string>block</string>
+ <key>Title</key>
+ <string>Bloquer</string>
+ <key>Titles</key>
+ <array>
+ <string>tous les types MIME</string>
+ <string>tous sauf ceux de la liste verte</string>
+ <string>seulement ceux de la liste rouge</string>
+ </array>
+ <key>Type</key>
+ <string>RadioButtons</string>
+ <key>Values</key>
+ <array>
+ <string>blockAll</string>
+ <string>useGreenlist</string>
+ <string>useRedlist</string>
+ </array>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <string></string>
+ <key>Key</key>
+ <string>greenlist</string>
+ <key>Title</key>
+ <string>Liste verte</string>
+ <key>Type</key>
+ <string>TextField</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <string>flash, futuresplash, silverlight</string>
+ <key>Key</key>
+ <string>redlist</string>
+ <key>Title</key>
+ <string>Liste rouge</string>
+ <key>Type</key>
+ <string>TextField</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <false/>
+ <key>Key</key>
+ <string>allowQT</string>
+ <key>Title</key>
+ <string>Autoriser le plugin QuickTime                          </string>
+ <key>Type</key>
+ <string>CheckBox</string>
+ </dict>
+ <dict>
+ <key>Title</key>
+ <string>Options vidéo</string>
+ <key>Type</key>
+ <string>Group</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <true/>
+ <key>Key</key>
+ <string>useH264</string>
+ <key>Title</key>
+ <string>Rechercher des vidéos pour remplacer             </string>
+ <key>Type</key>
+ <string>CheckBox</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <true/>
+ <key>Key</key>
+ <string>replaceFlash</string>
+ <key>Title</key>
+ <string>Flash                                             </string>
+ <key>Type</key>
+ <string>CheckBox</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <true/>
+ <key>Key</key>
+ <string>replaceSL</string>
+ <key>Title</key>
+ <string>Silverlight                                      </string>
+ <key>Type</key>
+ <string>CheckBox</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <true/>
+ <key>Key</key>
+ <string>replaceQT</string>
+ <key>Title</key>
+ <string>QuickTime                                    </string>
+ <key>Type</key>
+ <string>CheckBox</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <true/>
+ <key>Key</key>
+ <string>replaceWM</string>
+ <key>Title</key>
+ <string>Windows Media                             </string>
+ <key>Type</key>
+ <string>CheckBox</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <true/>
+ <key>Key</key>
+ <string>usePlaylists</string>
+ <key>Title</key>
+ <string>Utiliser les listes de lecture                               </string>
+ <key>Titles</key>
+ <array>
+ <string>Ne pas utiliser</string>
+ <string>N'utiliser qu'en dernier recours</string>
+ <string>Utiliser sans restrictions</string>
+ </array>
+ <key>Type</key>
+ <string>CheckBox</string>
+ <key>Values</key>
+ <array>
+ <real>1</real>
+ <real>2</real>
+ <real>3</real>
+ </array>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <false/>
+ <key>Key</key>
+ <string>H264autoload</string>
+ <key>Title</key>
+ <string>Effectuer les remplacements automatiquement</string>
+ <key>Type</key>
+ <string>CheckBox</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <string>autoplay</string>
+ <key>Key</key>
+ <string>H264behavior</string>
+ <key>Title</key>
+ <string>Une fois effectués</string>
+ <key>Titles</key>
+ <array>
+ <string>Attendre avant de télécharger</string>
+ <string>Commencer le téléchargement</string>
+ <string>Commencer la lecture automatiquement</string>
+ </array>
+ <key>Type</key>
+ <string>PopUpButton</string>
+ <key>Values</key>
+ <array>
+ <string>none</string>
+ <string>buffer</string>
+ <string>autoplay</string>
+ </array>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <real>2</real>
+ <key>Key</key>
+ <string>QTbehavior</string>
+ <key>Title</key>
+ <string>Codecs non natifs</string>
+ <key>Titles</key>
+ <array>
+ <string>Ne pas utiliser</string>
+ <string>N'utiliser qu'en dernier recours</string>
+ <string>Utiliser sans restrictions</string>
+ </array>
+ <key>Type</key>
+ <string>PopUpButton</string>
+ <key>Values</key>
+ <array>
+ <real>1</real>
+ <real>2</real>
+ <real>3</real>
+ </array>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <real>3</real>
+ <key>Key</key>
+ <string>maxresolution</string>
+ <key>Title</key>
+ <string>Résolution max</string>
+ <key>Titles</key>
+ <array>
+ <string>480p</string>
+ <string>720p</string>
+ <string>1080p</string>
+ <string>4K</string>
+ </array>
+ <key>Type</key>
+ <string>PopUpButton</string>
+ <key>Values</key>
+ <array>
+ <real>1</real>
+ <real>2</real>
+ <real>3</real>
+ <real>4</real>
+ </array>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <real>0.5</real>
+ <key>Key</key>
+ <string>volume</string>
+ <key>MaximumValue</key>
+ <real>1</real>
+ <key>StepValue</key>
+ <real>0.01</real>
+ <key>Title</key>
+ <string>Volume sonore</string>
+ <key>Type</key>
+ <string>Slider</string>
+ </dict>
+ <dict>
+ <key>Title</key>
+ <string>Liste blanche</string>
+ <key>Type</key>
+ <string>Group</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <false/>
+ <key>Key</key>
+ <string>uselocWhitelist</string>
+ <key>Title</key>
+ <string>Autoriser les plugins si l'adresse de la page     </string>
+ <key>Type</key>
+ <string>CheckBox</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <string>www.example.com, www.example2.com</string>
+ <key>Key</key>
+ <string>locwhitelist</string>
+ <key>Title</key>
+ <string>contient</string>
+ <key>Type</key>
+ <string>TextField</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <string></string>
+ <key>Key</key>
+ <string>locblacklist</string>
+ <key>Title</key>
+ <string>ne contient pas</string>
+ <key>Type</key>
+ <string>TextField</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <false/>
+ <key>Key</key>
+ <string>usesrcWhitelist</string>
+ <key>Title</key>
+ <string>Autoriser les plugins si l'adresse de l'objet       </string>
+ <key>Type</key>
+ <string>CheckBox</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <string></string>
+ <key>Key</key>
+ <string>srcwhitelist</string>
+ <key>Title</key>
+ <string>contient</string>
+ <key>Type</key>
+ <string>TextField</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <string></string>
+ <key>Key</key>
+ <string>srcblacklist</string>
+ <key>Title</key>
+ <string>ne contient pas</string>
+ <key>Type</key>
+ <string>TextField</string>
+ </dict>
+ <dict>
+ <key>Title</key>
+ <string>Éléments invisibles</string>
+ <key>Type</key>
+ <string>Group</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <false/>
+ <key>Key</key>
+ <string>loadInvisible</string>
+ <key>Title</key>
+ <string>Autoriser les éléments aux dimensions            </string>
+ <key>Type</key>
+ <string>CheckBox</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <real>1</real>
+ <key>Key</key>
+ <string>maxinvdim</string>
+ <key>Title</key>
+ <string>n'excédant pas</string>
+ <key>Titles</key>
+ <array>
+ <string>1 x 1 px</string>
+ <string>2 x 2 px</string>
+ <string>4 x 4 px</string>
+ <string>8 x 8 px</string>
+ </array>
+ <key>Type</key>
+ <string>PopUpButton</string>
+ <key>Values</key>
+ <array>
+ <real>1</real>
+ <real>2</real>
+ <real>4</real>
+ <real>8</real>
+ </array>
+ </dict>
+ <dict>
+ <key>Title</key>
+ <string>Menu contextuel</string>
+ <key>Type</key>
+ <string>Group</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <false/>
+ <key>Key</key>
+ <string>useWLcontext</string>
+ <key>Title</key>
+ <string>Ajouter à la liste blanche                                  </string>
+ <key>Type</key>
+ <string>CheckBox</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <false/>
+ <key>Key</key>
+ <string>useLAcontext</string>
+ <key>Title</key>
+ <string>Débloquer tous les plugins                               </string>
+ <key>Type</key>
+ <string>CheckBox</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <false/>
+ <key>Key</key>
+ <string>useVScontext</string>
+ <key>Title</key>
+ <string>Voir la vidéo sur le site                                     </string>
+ <key>Type</key>
+ <string>CheckBox</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <false/>
+ <key>Key</key>
+ <string>useQTcontext</string>
+ <key>Title</key>
+ <string>Ouvrir dans QuickTime Player                           </string>
+ <key>Type</key>
+ <string>CheckBox</string>
+ </dict>
+ <dict>
+ <key>Type</key>
+ <string>Separator</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <string>textonly</string>
+ <key>Key</key>
+ <string>sifrReplacement</string>
+ <key>Title</key>
+ <string>Texte sIFR</string>
+ <key>Titles</key>
+ <array>
+ <string>N'afficher que le texte</string>
+ <string>Considérer comme Flash</string>
+ <string>Autoriser</string>
+ </array>
+ <key>Type</key>
+ <string>PopUpButton</string>
+ <key>Values</key>
+ <array>
+ <string>textonly</string>
+ <string>normal</string>
+ <string>autoload</string>
+ </array>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <real>1</real>
+ <key>Key</key>
+ <string>opacity</string>
+ <key>MaximumValue</key>
+ <real>1</real>
+ <key>Secure</key>
+ <false/>
+ <key>StepValue</key>
+ <real>0.01</real>
+ <key>Title</key>
+ <string>Opacité</string>
+ <key>Type</key>
+ <string>Slider</string>
+ </dict>
+ <dict>
+ <key>DefaultValue</key>
+ <string></string>
+ <key>Key</key>
+ <string>debug</string>
+ <key>Title</key>
+ <string>Activer le mode de débogage                           </string>
+ <key>Type</key>
+ <string>Hidden</string>
+ </dict>
</array>
</plist>
120 ClickToPlugin.fr.safariextension/functions.js
View
@@ -1,91 +1,63 @@
-function getSrcOf(element) {
+function getInfo(element, url) {
+ // gathers attributes of the element that might be needed later on
+ // Done by a single function so that we only loop once through the <param> children
+ var info = new Object();
var tmpAnchor = document.createElement("a");
switch (element.tag) {
case "embed":
+ if(element.hasAttribute("qtsrc")) {
+ tmpAnchor.href = element.getAttribute("qtsrc");
+ info.src = tmpAnchor.href;
+ }
+ if(element.hasAttribute("href")) {
+ tmpAnchor.href = element.getAttribute("href");
+ info.href = tmpAnchor.href;
+ }
+ if(element.hasAttribute("target")) {
+ info.target = element.getAttribute("target");
+ }
if(element.hasAttribute("previewimage")) {
tmpAnchor.href = element.getAttribute("previewimage");
- element.image = tmpAnchor.href;
+ info.image = tmpAnchor.href;
}
- if(element.src) tmpAnchor.href = element.src;
- if(element.hasAttribute("qtsrc")) tmpAnchor.href = element.getAttribute("qtsrc");
- element.presource = tmpAnchor.href;
- if(element.hasAttribute("target")) element.otherInfo.target = element.getAttribute("target");
- if(element.hasAttribute("href")) {
- tmpAnchor.href = element.getAttribute("href");
- } else {
- delete element.presource;
- if(!element.src) return "";
- }
- return tmpAnchor.href;
break;
case "object":
- // NOTE: For silverlight objects element.data is used for something else than the source
- // and a param named 'source' is used for the source. So we look for that before
- // using element.data
var paramElements = element.getElementsByTagName("param");
- var srcParam = null; var qtsrcParam = null;
for (i = 0; i < paramElements.length; i++) {
- if(!paramElements[i].hasAttribute("value")) continue;
+ if(!paramElements[i].hasAttribute("value")) continue;
var paramName = paramElements[i].getAttribute("name").toLowerCase(); // name attribute is mandatory!
- // this is a bit shaky...
- // maybe should check first for mimetype and then let getSrcOf depend on type
- // eg source for silverlight; src for flash, qt, realplayer; filename for wm...
- // this would require 2 successive canLoads? or just use the type attribute??
- // it seems to always be specified for SL, but not QT (uses classid instead)
- // damn... maybe better to pass the whole HTMLToString(element) to the global page after all?
- if(paramName == "previewimage") {
- var tmpAnchor2 = document.createElement("a");
- tmpAnchor2.href = paramElements[i].getAttribute("value");
- element.image = tmpAnchor2.href;
- } else if(paramName == "src") {
- srcParam = i;
- if(!element.presource) {
- var tmpAnchor2 = document.createElement("a");
- tmpAnchor2.href = paramElements[i].getAttribute("value");
- element.presource = tmpAnchor2.href;
- }
- //element.otherInfo.src = paramElements[i].getAttribute("value");
- } else if (paramName == "qtsrc") {
- qtsrcParam = i;
- var tmpAnchor2 = document.createElement("a");
- tmpAnchor2.href = paramElements[i].getAttribute("value");
- element.presource = tmpAnchor2.href;
- //element.otherInfo.qtsrc = paramElements[i].getAttribute("value");
- } else if (paramName == "target") element.otherInfo.target = paramElements[i].getAttribute("value");
- else if(paramName == "movie" || paramName == "source" || paramName == "href" || paramName == "filename") { //|| paramName == "url") { // for oleobject, not supported on Safari (what about the Win version?)
- tmpAnchor.href = paramElements[i].getAttribute("value");
+ switch(paramName) {
+ case "source": // Silverlight true source
+ tmpAnchor.href = paramElements[i].getAttribute("value");
+ info.src = tmpAnchor.href;
+ break;
+ case "qtsrc": // QuickTime true source
+ tmpAnchor.href = paramElements[i].getAttribute("value");
+ info.src = tmpAnchor.href;
+ break;
+ case "href": // QuickTime
+ tmpAnchor.href = paramElements[i].getAttribute("value");
+ info.href = tmpAnchor.href;
+ break;
+ case "target": // QuickTime
+ info.target = paramElements[i].getAttribute("value");
+ break;
+ case "previewimage": // DivX
+ tmpAnchor.href = paramElements[i].getAttribute("value");
+ info.image = tmpAnchor.href;
+ break;
}
}
- if(tmpAnchor.href) return tmpAnchor.href;
- if(qtsrcParam != null) {
- element.presource = null;
- tmpAnchor.href = paramElements[qtsrcParam].getAttribute("value");
- return tmpAnchor.href;
- } else if(srcParam != null) {
- element.presource = null;
- tmpAnchor.href = paramElements[srcParam].getAttribute("value");
- return tmpAnchor.href;
- }
- if(element.data) {
- tmpAnchor.href = element.data;
- return tmpAnchor.href;
- } else {
- var embedElements = element.getElementsByTagName("embed");
- if(embedElements.length == 0) return "";
- embedElements[0].tag = "embed";
- return getSrcOf(embedElements[0]);
- }
- return "";
- break;
- case "applet":
- if(element.code) {
- tmpAnchor.href = element.code;
- } else if(element.hasAttribute("archive")) {
- tmpAnchor.href = element.getAttribute("archive");
- } else return "";
- return tmpAnchor.href;
break;
}
+ if(!info.src) {
+ if(!url) info.src = "";
+ else {
+ tmpAnchor.href = url;
+ info.src = tmpAnchor.href;
+ }
+ }
+ return info;
}
function getParamsOf(element) {
@@ -132,7 +104,7 @@ function getTypeOf(element) {
var paramElements = element.getElementsByTagName("param");
for (i = 0; i < paramElements.length; i++) {
if(paramElements[i].getAttribute("name").toLowerCase() == "type") {
- return paramElements[i].getAttribute("value");
+ return paramElements[i].getAttribute("value");
}
}
var embedChildren = element.getElementsByTagName("embed");
11 ClickToPlugin.fr.safariextension/global.html
View
@@ -1,9 +1,10 @@
<!DOCTYPE html>
<html>
- <head>
- <title>Global HTML</title>
+ <head>
+ <title>Global HTML</title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script type="text/javascript" src="globalfunctions.js"></script>
- <script type="text/javascript" src="killers/YouTubeKiller.js"></script>
+ <script type="text/javascript" src="killers/YouTubeKiller.js"></script>
<script type="text/javascript" src="killers/VimeoKiller.js"></script>
<script type="text/javascript" src="killers/DailymotionKiller.js"></script>
<script type="text/javascript" src="killers/VeohKiller.js"></script>
@@ -13,6 +14,6 @@
<script type="text/javascript" src="killers/WMKiller.js"></script>
<script type="text/javascript" src="killers/DivXKiller.js"></script>
<script type="text/javascript" src="global.js"></script>
- </head>
- <body></body>
+ </head>
+ <body></body>
</html>
262 ClickToPlugin.fr.safariextension/global.js
View
@@ -1,81 +1,19 @@
var CTP_instance = 0; // incremented by one whenever a ClickToPlugin instance with content is created
const killers = [new YouTubeKiller(), new VimeoKiller(), new DailymotionKiller(), new VeohKiller(), new JWKiller(), new SLKiller(), new QTKiller(), new WMKiller(), new DivXKiller()];
-function pluginName(plugin) {
- if(plugin.name == "Shockwave Flash") return "Flash";
- if(plugin.name == "Silverlight Plug-In") return "Silverlight";
- if(plugin.name.match("Java")) return "Java";
- if(plugin.name.match("QuickTime")) return "QuickTime";
- if(plugin.name.match("Flip4Mac")) return "WM";
- if(plugin.name == "iPhotoPhotocast") return "iPhoto";
- if(plugin.name == "Quartz Composer Plug-In") return "Quartz";
- if(plugin.name == "VideoLAN VLC Plug-in") return "VLC";
- if(plugin.name == "DivX Web Player") return "DivX";
- if(plugin.name == ("RealPlayer Plugin.plugin")) return "RealPlayer";
- return plugin.name;
- /*switch (plugin.name) {
- case "Flip4Mac Windows Media Web Plugin 2.3.4": return "WM";
- case "Flip4Mac Windows Media Plugin 2.3.4": return "WM";
- case "Silverlight Plug-In": return "Silverlight";
- case "Shockwave Flash": return "Flash";
- case "Switchable Java Plug-in for WebKit": return "Java";
- case "Java Plug-In 2 for NPAPI Browsers": return "Java";
- case "iPhotoPhotocast": return "iPhoto";
- case "QuickTime Plug-in 7.6.6": return "QuickTime";
- case "Quartz Composer Plug-In": return "Quartz";
- default: return plugin.name;
- }*/
-}
-
-/*
-LIST OF CLASSID (What is this stuff anyway?)
-QuickTime: 02BF25D5-8C17-4B23-BC80-D3488ABDDC6B
-WMP 6: 22d6f312-b0f6-11d0-94ab-0080c74c7e95
-WMP >6: 6BF52A52-394A-11D3-B153-00C04F79FAA6
-Flash: d27cdb6e-ae6d-11cf-96b8-444553540000
-Real Player: CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA
-?? calendar: 8E27C92B-1264-101C-8A2F-040224009C02
-?? graphics: 369303C2-D7AC-11D0-89D5-00A0C90833E6
-?? slider: F08DF954-8592-11D1-B16A-00C0F0283628
-DivX: 67DABFBF-D0AB-41fa-9C46-CC0F21721616
-*/
-
-
-function getPluginForType(MIMEType) { // MIMEType is a string
- for(var i = 0; i < navigator.plugins.length; i++) {
- for(var j = 0; j < navigator.plugins[i].length; j++) {
- if(navigator.plugins[i][j].type == MIMEType) return navigator.plugins[i];
- }
- }
- return null;
-}
-
-function getPluginAndTypeForExt(ext) {
- var suffixes = null;
- for(var i = 0; i < navigator.plugins.length; i++) {
- for(var j = 0; j < navigator.plugins[i].length; j++) {
- suffixes = navigator.plugins[i][j].suffixes.split(",");
- for(var k = 0; k < suffixes.length; k++) {
- if(ext == suffixes[k]) return {"plugin": navigator.plugins[i], "type": navigator.plugins[i][j].type};
- }
- }
- }
- return {"plugin": null, "type": null};
-}
-
function blockOrAllow(data) { // returns null if element can be loaded, the name of the plugin otherwise
// no source and no type -> must allow, it's probably going to pass through here again after being modified by a script
if(!data.src && !data.type && !data.classid) return null;
// native Safari support
- var ext = extractExt(data.src); // used later as well
- if(data.type) {
- if(isNativeType(data.type)) return null;
- } else {
- if(isNativeExt(ext)) return null;
- }
-
+ var ext = extractExt(data.src); // used later as well
+ if(data.type) {
+ if(isNativeType(data.type)) return null;
+ } else {
+ if(isNativeExt(ext)) return null;
+ }
+
// try not to block objects created by other extensions
if(data.src.substring(0,19) == "safari-extension://") return null;
@@ -87,55 +25,55 @@ function blockOrAllow(data) { // returns null if element can be loaded, the name
}
// Deal with whitelisted content
- if(safari.extension.settings["uselocWhitelist"]) {
+ if(safari.extension.settings["uselocWhitelist"]) {
var locwhitelist = safari.extension.settings["locwhitelist"].replace(/\s+/g,"");
var locblacklist = safari.extension.settings["locblacklist"].replace(/\s+/g,"");
- if(locwhitelist) {
- locwhitelist = locwhitelist.split(/,(?![^\(]*\))/);
+ if(locwhitelist) {
+ locwhitelist = locwhitelist.split(/,(?![^\(]*\))/); // matches all , except those in parentheses (used in regexp)
if(matchList(locwhitelist, data.location)) return null;
- }
- if(locblacklist) {
- locblacklist = locblacklist.split(/,(?![^\(]*\))/);
- if(!matchList(locblacklist, data.location)) return null;
- }
+ }
+ if(locblacklist) {
+ locblacklist = locblacklist.split(/,(?![^\(]*\))/);
+ if(!matchList(locblacklist, data.location)) return null;
+ }
}
- if(safari.extension.settings["usesrcWhitelist"]) {
- var srcwhitelist = safari.extension.settings["srcwhitelist"].replace(/\s+/g,"");
+ if(safari.extension.settings["usesrcWhitelist"]) {
+ var srcwhitelist = safari.extension.settings["srcwhitelist"].replace(/\s+/g,"");
var srcblacklist = safari.extension.settings["srcblacklist"].replace(/\s+/g,"");
- if(srcwhitelist) {
- srcwhitelist = srcwhitelist.split(/,(?![^\(]*\))/);
+ if(srcwhitelist) {
+ srcwhitelist = srcwhitelist.split(/,(?![^\(]*\))/);
if(matchList(srcwhitelist, data.src)) return null;
- }
- if(locblacklist) {
- srcblacklist = srcblacklist.split(/,(?![^\(]*\))/);
- if(!matchList(srcblacklist, data.src)) return null;
- }
- }
-
+ }
+ if(locblacklist) {
+ srcblacklist = srcblacklist.split(/,(?![^\(]*\))/);
+ if(!matchList(srcblacklist, data.src)) return null;
+ }
+ }
+
// We use a 'soft' method to get the MIME type
// It is not necessarily correct, but always returns a MIME type handled by the correct plugin
// To get the correct MIME type an AJAX request would be needed, out of the question here!
var plugin = null;
- var MIMEType = data.type.replace(/\s+/g,"");
- var badgeLabel = "?";
- if(MIMEType) {
- badgeLabel = MIMEType.split(";")[0].split("/")[1]; // temporary unless no plugin can be found to play MIMEType
- plugin = getPluginForType(MIMEType);
- }
+ var MIMEType = data.type;
+ var pluginName = "?";
+ if(MIMEType) plugin = getPluginForType(MIMEType);
if(!plugin && data.src) {
var x = getPluginAndTypeForExt(ext);
plugin = x.plugin;
MIMEType = x.type;
}
- if(plugin) badgeLabel = pluginName(plugin);
+ if(plugin) pluginName = getPluginNameFromPlugin(plugin);
+ else if(MIMEType) pluginName = getPluginNameFromType(MIMEType);
+ else if(data.classid) pluginName = getPluginNameFromClassid(data.classid.replace("clsid:", ""));
- if(safari.extension.settings["allowQT"] && badgeLabel == "QuickTime") return null;
+ if(safari.extension.settings["allowQT"] && pluginName == "QuickTime") return null;
+ // Use greenlist/redlist
if(MIMEType) {
if(safari.extension.settings["block"] == "useRedlist") {
var redlist = safari.extension.settings["redlist"].replace(/\s+/g,"");
if(!redlist) return null;
- redlist = redlist.split(/,(?![^\(]*\))/); // matches all , except those in parentheses (used in regexp)
+ redlist = redlist.split(/,(?![^\(]*\))/);
if(!matchList(redlist, MIMEType, true)) return null;
} else if(safari.extension.settings["block"] == "useGreenlist") {
var greenlist = safari.extension.settings["greenlist"].replace(/\s+/g,"");
@@ -145,18 +83,16 @@ function blockOrAllow(data) { // returns null if element can be loaded, the name
}
}
}
- // At this point we know we'll have to block the element
+ // At this point we know we should block the element
- for(var key in data.otherInfo) {
- if(key == "target" && data.otherInfo.target == "quicktimeplayer") {
- // A quicktime object that would launch QTP
- if(confirm("Un objet QuickTime voudrait lancer le lecture de\n\n" + data.src + "\n\ndans QuickTime Player. Voulez-vous l'autoriser?")) {
- return null;
- }
+ // Exception: ask the user what to do if a QT object would launch QTP
+ if(data.launchInQTP) {
+ if(confirm("Un objet QuickTime voudrait lancer le lecture de\n\n" + data.launchInQTP + "\n\ndans QuickTime Player. Voulez-vous l'autoriser?")) {
+ return null;
}
}
- return badgeLabel;
+ return pluginName;
}
@@ -174,11 +110,6 @@ function respondToMessage(event) {
case "killPlugin":
killPlugin(event.message);
break;
- //case "downloadMedia":
- //var newTab = safari.application.activeBrowserWindow.openTab("foreground");
- //newTab.url = event.message + ".zip";
- //prompt("Copy the following URL and paste it into the Downloads window.", event.message);
- //break;
}
}
@@ -197,73 +128,60 @@ function respondToCanLoad(message) {
}
}
-function printMedia(mediaType) {
- switch(mediaType) {
- case "video": return "Video";
- case "audio": return "Audio";
- default: return "Video";
- }
-}
-
-function printPlugin(pluginName) {
- if(/[A-Z]/.test(pluginName)) return pluginName;
- return "Plugin";
-}
-
function handleContextMenu(event) {
- if(!event.userInfo.CTPInstance) {
- if(safari.extension.settings["useLAcontext"] && event.userInfo.blocked > 0) event.contextMenu.appendContextMenuItem("loadall", "Débloquer tous les plugins (" + event.userInfo.blocked + ")");
+ if(!event.userInfo.instance) {
+ if(safari.extension.settings["useLAcontext"] && event.userInfo.blocked > 0) event.contextMenu.appendContextMenuItem("loadall", "Débloquer tous les plugins (" + event.userInfo.blocked + ")");
if(safari.extension.settings["useWLcontext"]) {
- event.contextMenu.appendContextMenuItem("locwhitelist", "Ajouter à la liste blanche\u2026");
+ event.contextMenu.appendContextMenuItem("locwhitelist", "Ajouter à la liste blanche\u2026");
}
return;
}
+ var pluginName = /[A-Z]/.test(event.userInfo.plugin) ? event.userInfo.plugin : "Plugin";
if(event.userInfo.isH264) {
- event.contextMenu.appendContextMenuItem(event.userInfo.CTPInstance + "," + event.userInfo.elementID + ",reloadPlugin", "Relancer avec " + event.userInfo.plugin);
- if(safari.extension.settings["useQTcontext"]) event.contextMenu.appendContextMenuItem(event.userInfo.CTPInstance + "," + event.userInfo.elementID + ",qtp", "Ouvrir dans QuickTime Player");
- if(event.userInfo.siteInfo && safari.extension.settings["useVScontext"]) event.contextMenu.appendContextMenuItem("gotosite", "Voir la vidéo sur " + event.userInfo.siteInfo.name);
+ event.contextMenu.appendContextMenuItem(event.userInfo.instance + "," + event.userInfo.elementID + ",reload", "Relancer avec " + pluginName);
+ if(safari.extension.settings["useQTcontext"]) event.contextMenu.appendContextMenuItem(event.userInfo.instance + "," + event.userInfo.elementID + ",qtp", "Ouvrir avec QuickTime Player");
+ if(event.userInfo.siteInfo && safari.extension.settings["useVScontext"]) event.contextMenu.appendContextMenuItem("gotosite", "Voir la vidéo sur " + event.userInfo.siteInfo.name);
} else {
if(event.userInfo.hasH264) {
- //event.contextMenu.appendContextMenuItem(event.userInfo.CTPInstance + "," + event.userInfo.elementID + ",video", "Load " + printMedia(event.userInfo.mediaType));
- event.contextMenu.appendContextMenuItem(event.userInfo.CTPInstance + "," + event.userInfo.elementID + ",plugin", "Lancer " + printPlugin(event.userInfo.plugin));
- event.contextMenu.appendContextMenuItem(event.userInfo.CTPInstance + "," + event.userInfo.elementID + ",remove", "Supprimer " + printPlugin(event.userInfo.plugin));
- //if(safari.extension.settings["useLAcontext"] && event.userInfo.blocked > 1) event.contextMenu.appendContextMenuItem("loadall", "Load All Plugins (" + event.userInfo.blocked + ")");
- if(safari.extension.settings["useQTcontext"]) event.contextMenu.appendContextMenuItem(event.userInfo.CTPInstance + "," + event.userInfo.elementID + ",qtp", "Ouvrir dans QuickTime Player");
- if(event.userInfo.siteInfo && safari.extension.settings["useVScontext"]) event.contextMenu.appendContextMenuItem("gotosite", "Voir la vidéo sur " + event.userInfo.siteInfo.name);
- } else {
- event.contextMenu.appendContextMenuItem(event.userInfo.CTPInstance + "," + event.userInfo.elementID + ",remove", "Supprimer " + printPlugin(event.userInfo.plugin));
- //if(safari.extension.settings["useLAcontext"] && event.userInfo.blocked > 1) event.contextMenu.appendContextMenuItem("loadall", "Load All Plugins (" + event.userInfo.blocked + ")");
- }
+ event.contextMenu.appendContextMenuItem(event.userInfo.instance + "," + event.userInfo.elementID + ",plugin", "Lancer " + pluginName);
+ event.contextMenu.appendContextMenuItem(event.userInfo.instance + "," + event.userInfo.elementID + ",remove", "Supprimer " + pluginName);
+ //if(safari.extension.settings["useLAcontext"] && event.userInfo.blocked > 1) event.contextMenu.appendContextMenuItem("loadall", "Load All Plugins (" + event.userInfo.blocked + ")");
+ if(safari.extension.settings["useQTcontext"]) event.contextMenu.appendContextMenuItem(event.userInfo.instance + "," + event.userInfo.elementID + ",qtp", "Ouvrir avec QuickTime Player");
+ if(event.userInfo.siteInfo && safari.extension.settings["useVScontext"]) event.contextMenu.appendContextMenuItem("gotosite", "Voir la vidéo sur " + event.userInfo.siteInfo.name);
+ } else {
+ event.contextMenu.appendContextMenuItem(event.userInfo.instance + "," + event.userInfo.elementID + ",remove", "Supprimer " + pluginName);
+ //if(safari.extension.settings["useLAcontext"] && event.userInfo.blocked > 1) event.contextMenu.appendContextMenuItem("loadall", "Load All Plugins (" + event.userInfo.blocked + ")");
+ }
if(safari.extension.settings["useWLcontext"]) {
- event.contextMenu.appendContextMenuItem("srcwhitelist", "Ajouter à la liste blanche\u2026");
+ event.contextMenu.appendContextMenuItem("srcwhitelist", "Ajouter à la liste blanche\u2026");
}
// BEGIN DEBUG
if(safari.extension.settings["debug"]) {
- event.contextMenu.appendContextMenuItem(event.userInfo.CTPInstance + "," + event.userInfo.elementID + ",show", "Voir l'élément " + event.userInfo.CTPInstance + "." + event.userInfo.elementID);
+ event.contextMenu.appendContextMenuItem(event.userInfo.instance + "," + event.userInfo.elementID + ",show", "Voir l'élément " + event.userInfo.instance + "." + event.userInfo.elementID);
}
//END DEBUG
}
}
function doCommand(event) {
- switch(event.command) {
- case "gotosite":
- var newTab = safari.application.activeBrowserWindow.openTab("foreground");
- newTab.url = event.userInfo.siteInfo.url;
- break;
- case "locwhitelist":
- handleWhitelisting(true, event.userInfo.location);
- break;
- case "srcwhitelist":
- handleWhitelisting(false, event.userInfo.src);
- break;
- case "loadall":
- safari.application.activeBrowserWindow.activeTab.page.dispatchMessage("loadAll", "");
- break;
- default:
- safari.application.activeBrowserWindow.activeTab.page.dispatchMessage("loadContent", event.command);
- break;
- }
+ switch(event.command) {
+ case "gotosite":
+ var newTab = safari.application.activeBrowserWindow.openTab("foreground");
+ newTab.url = event.userInfo.siteInfo.url;
+ break;
+ case "locwhitelist":