Posts

Showing posts with the label Google Chrome Extension

Callback Returns Undefined With Chrome.storage.sync.get

Answer : The chrome.storage API is asynchronous - it doesn't return it directly, rather passing it as an argument to the callback function. The function call itself always returns undefined . This is often used to allow other methods to run without having to wait until something responds or completes - an example of this is setTimeout (only difference is that it returns a timer value, not undefined ). For example, take this: setTimeout(function () { alert(1); }, 10000); alert(0); Because setTimeout is asynchronous, it will not stop all code until the entire function completes, rather returning initially, only calling a function when it is completed later on - this is why 0 comes up before 1. For this reason, you cannot simply do something like: // "foo" will always be undefined var foo = asyncBar(function (e) { return e; }); Generally, you should put what you want to do in your callback (the function that is called when the asynchronous function i...

ACE Editor Autocomplete - Custom Strings

Answer : you need to add a completer like this var staticWordCompleter = { getCompletions: function(editor, session, pos, prefix, callback) { var wordList = ["foo", "bar", "baz"]; callback(null, wordList.map(function(word) { return { caption: word, value: word, meta: "static" }; })); } } langTools.setCompleters([staticWordCompleter]) // or editor.completers = [staticWordCompleter] If you want to persist the old keyword list and want to append a new list var staticWordCompleter = { getCompletions: function(editor, session, pos, prefix, callback) { var wordList = ["foo", "bar", "baz"]; callback(null, [...wordList.map(function(word) { return { caption: word, value: word, meta: "static" }; }), ...ses...

Convert Web Extension To Safari App Extension

Image
Answer : You should be able to reuse Content Scripts from your Web-Extensions (but you need to rewrite code to be able to send/receive messages with "background"). Background script will have to be re-written in Swift or Objective-C. You need to developp: a Mac Host Application (which will be a companion to the Extension) : Swift or Objective-C (this app must have minimum features to pass Apple review - check the Apple guidelines for Mac Apps) the extension : in Swift or Objective-C + HTML/JS (as for other browsers) The code in Swift (or Obj-C) for the extension is the equivalent of the background page you have in Web Extensions. It will control the toolbar button, life-cycle of the extension and can talk with injected scripts. You have an (small) example on Apple website : https://developer.apple.com/documentation/safariservices/safari_app_extensions?changes=_2&language=objc You should not use Extension Builder anymore (accessible from Developer menu in Safari) since ...

Can I Edit A Google Chrome Theme?

Answer : A theme is a special kind of extension that changes the way the browser looks. Themes are packaged like regular extensions, but they don't contain JavaScript or HTML code. You can download any theme and modify it by editing the manifest.json file. Colors are in RGB format. To find the strings you can use within the "colors" field, look for kColor* strings in theme_service.cc. Image resources use paths relative to the root of the extension. You can override any of the images that are specified by kThemeableImages in theme_service.cc. Just remove the "IDR_" and convert the remaining characters to lowercase. Reference: https://developer.chrome.com/extensions/themes As was mentioned, you can find it in appdata folder, e.g.: C:\Users\mizer\AppData\Local\Google\Chrome\User Data\Default\Extensions\ Hint: Sort folders by date and you can easily find the one you want :) You can find it in your appdata folders. Mine was located at: C:\Users\home\AppD...