Browse Source

minor code review

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

1
platform/firefox/vapi-background.js

@ -1160,7 +1160,6 @@ var httpObserver = {
// https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/Limitations_of_chrome_scripts // https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/Limitations_of_chrome_scripts
tabIdFromChannel: function(channel) { tabIdFromChannel: function(channel) {
var aWindow; var aWindow;
if ( channel.notificationCallbacks ) { if ( channel.notificationCallbacks ) {
try { try {
var loadContext = channel var loadContext = channel

5
src/js/contentscript-end.js

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

11
src/js/start.js

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

Loading…
Cancel
Save