Browse Source

minor code review

pull/2/head
gorhill 10 years ago
parent
commit
3d3160efdf
  1. 5
      platform/firefox/vapi-background.js
  2. 5
      src/js/contentscript-end.js
  3. 11
      src/js/start.js

5
platform/firefox/vapi-background.js

@ -1160,12 +1160,11 @@ var httpObserver = {
// https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/Limitations_of_chrome_scripts
tabIdFromChannel: function(channel) {
var aWindow;
if ( channel.notificationCallbacks ) {
try {
var loadContext = channel
.notificationCallbacks
.getInterface(Ci.nsILoadContext);
.notificationCallbacks
.getInterface(Ci.nsILoadContext);
if ( loadContext.topFrameElement ) {
return vAPI.tabs.getTabId(loadContext.topFrameElement);
}

5
src/js/contentscript-end.js

@ -150,6 +150,7 @@ var collapser = (function() {
var srcProps = {
'img': 'src'
};
var reURLplaceholder = /\{\{url\}\}/g;
var PendingRequest = function(target) {
this.id = requestId++;
@ -207,7 +208,9 @@ var collapser = (function() {
if ( tagName === 'iframe' ) {
target.setAttribute(
'src',
'data:text/html,' + encodeURIComponent(placeholders.iframe.replace('{{url}}', request.url))
'data:text/html,' + encodeURIComponent(
placeholders.iframe.replace(reURLplaceholder, request.url)
)
);
continue;
}

11
src/js/start.js

@ -67,8 +67,13 @@ var defaultLocalUserSettings = {
'padding: 2px;',
'white-space: nowrap;',
'}',
'a { ',
'color: inherit;',
'padding: 0 3px;',
'text-decoration: none;',
'}',
'</style></head><body>',
'{{url}}',
'<a href="{{url}}" title="{{url}}" target="_blank">&#x2191;</a>{{url}}',
'</body></html>'
].join(''),
placeholderImage: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
@ -97,9 +102,9 @@ var onAllDone = function() {
if ( defaultLocalUserSettings.hasOwnProperty(key) === false ) {
continue;
}
if ( vAPI.localStorage.getItem(key) === null ) {
//if ( vAPI.localStorage.getItem(key) === null ) {
vAPI.localStorage.setItem(key, defaultLocalUserSettings[key]);
}
//}
}
};

Loading…
Cancel
Save