Exemple #1
0
        public void LoadFromConsole()
        {
            Columns                  = ColoredConsole.Read("Speed dial columns: ", Columns);
            ThumbnailWidth           = ColoredConsole.Read("Thumbnail width: ", ThumbnailWidth);
            ThumbnailHeight          = ColoredConsole.Read("Thumbnail height: ", ThumbnailHeight);
            MarginX                  = ColoredConsole.Read("Horizontal space between thumbnails: ", MarginX);
            MarginY                  = ColoredConsole.Read("Vertical space between thumbnails: ", MarginY);
            DisableBuiltInThumbnails = ColoredConsole.Read("Disable built-in thumbnails: ", DisableBuiltInThumbnails);
            AddCustomThumbnails      = ColoredConsole.Read("Add custom thumbnails: ", AddCustomThumbnails);
            CropPageForThumbnail     = ColoredConsole.Read("Crop page for thumbnail like in Opera 12: ", CropPageForThumbnail);
            if (CropPageForThumbnail)
            {
                for (; ;)
                {
                    CropArea = ColoredConsole.Read("Crop area (top left 1-100% of the page): ", CropArea);
                    ColoredConsole.WriteLine();
                    if (CropArea > 0 && CropArea <= 100)
                    {
                        double ratio = 100.0 / CropArea;

                        ColoredConsole.WriteLine("~y~KWarning:~k~Y each thumbnail will consume {0:G3}x memory than without cropping.~N", ratio * ratio);
                        ColoredConsole.WriteLine();
                        if (ColoredConsole.Read("I would like to modify the value: ", false))
                        {
                            ColoredConsole.WriteLine();
                            continue;
                        }
                        break;
                    }

                    ColoredConsole.WriteLine("~r~WError:~k~R invalid crop area.~N");
                    ColoredConsole.WriteLine();
                }

                CropPageForThumbnail = CropArea != 100;
                ColoredConsole.WriteLine();
            }

            if (AddCustomThumbnails)
            {
                string[] fileNames = Directory.GetFiles("sdimages", "*.png");
                for (int n = 0; n < fileNames.Length; n++)
                {
                    string fileName = fileNames[n];
                    string name     = Path.GetFileNameWithoutExtension(fileName);

                    ColoredConsole.WriteLine("Adding thumbnail for ~W{0}~N ...", name);
                    Image image = Image.FromFile(fileName);
                    if (image.Width != ThumbnailWidth || image.Height != ThumbnailHeight)
                    {
                        ColoredConsole.WriteLine("~y~KWarning:~k~Y thumbnail image resolution is not {0}x{1}.~N", ThumbnailWidth, ThumbnailHeight);
                    }

                    CustomThumbnails.Add(name, "data:image/png;base64," + Convert.ToBase64String(File.ReadAllBytes(fileName)));
                }
            }
        }
Exemple #2
0
        public void LoadFromConsole()
        {
            if (Patches.Count > 0)
            {
                ColoredConsole.WriteLine();
                foreach (KeyValuePair <string, CssPatch> kvp in Patches)
                {
                    kvp.Value.IsEnabled = ColoredConsole.Read(kvp.Value.Description + ": ", kvp.Value.IsEnabled);
                }

                ColoredConsole.WriteLine();
            }
        }
Exemple #3
0
        public void LoadFromConsole()
        {
            DeletePartnerSearchEngines = ColoredConsole.Read("Delete partner search engines: ", DeletePartnerSearchEngines);
            if (!DeletePartnerSearchEngines)
            {
                return;
            }

            DefaultUrl           = ColoredConsole.Read("Default search engine URL: ", CalculateMaxLength(BuiltinUrl), DefaultUrl);
            DefaultName          = ColoredConsole.Read("Default search engine name: ", CalculateMaxLength(BuiltinName), DefaultName);
            DefaultKeyword       = ColoredConsole.Read("Default search engine keyword: ", 1, DefaultKeyword);
            DefaultFavicon       = ColoredConsole.Read("Default search engine favicon URL: ", CalculateMaxLength(BuiltinFavicon), DefaultFavicon);
            DefaultSuggestionUrl = ColoredConsole.Read("Default search engine suggestion URL: ", CalculateMaxLength(BuiltinSuggestionUrl), DefaultSuggestionUrl);
        }
Exemple #4
0
        public static int Main(string[] args)
        {
            int result;

            try
            {
                ColoredConsole.WriteLine("~WOpera Speed Dial Patch (build 20131124)~N");
                ColoredConsole.WriteLine("~WCopyright (c) 2013 dqdb~N");
                ColoredConsole.WriteLine();
                ColoredConsole.WriteLine("Thanks to ~WIzer0~N for all patches.");
                ColoredConsole.WriteLine();
                Settings settings = new Settings();
                settings.LoadFromConfigFile();
                settings.LoadFromConsole();
                settings.SaveToConfigFile();
                ColoredConsole.WriteLine();

                string pakFileName = FindLatestOperaPak(settings.OperaFolder);
                if (pakFileName == null)
                {
                    ColoredConsole.WriteLine("~r~WError:~k~R unable to find an ~r~Wopera.pak~N to patch.~N");
                    return(1);
                }

                OperaVersion version;

                try
                {
                    version = GetOperaPakVersion(pakFileName);
                }
                catch (Exception)
                {
                    ColoredConsole.WriteLine("~r~WError:~k~R unable to get version number from ~r~W{0}~k~R.~N", pakFileName);
                    return(1);
                }

                ColoredConsole.WriteLine("Opera version: ~W{0}~N", version);

                OperaPatch operaPatch = OperaPatches.FindWithHeuristics(settings, pakFileName);
                if (operaPatch == null)
                {
                    ColoredConsole.WriteLine();
                    ColoredConsole.WriteLine("~r~WError:~k~R this Opera version is not supported yet.~N");
                    return(1);
                }

                ColoredConsole.WriteLine();
                ColoredConsole.WriteLine("Processing ...");
                ColoredConsole.WriteLine();
                ColoredConsole.WriteLine("OperaPackHashOffset: ~W0x{0:x8}~N", operaPatch.OperaPakHashOffset);
                ColoredConsole.WriteLine("SpeeddialLayoutJs: ~W{0}~N", operaPatch.SpeeddialLayoutJs);
                ColoredConsole.WriteLine("StartPageHtml: ~W{0}~N", operaPatch.StartPageHtml);
                ColoredConsole.WriteLine("PreinstalledSpeeddialsJs: ~W{0}~N", operaPatch.PreinstalledSpeeddialsJs);
                ColoredConsole.WriteLine("SpeeddialSuggestionsJs: ~W{0}~N", operaPatch.SpeeddialSuggestionsJs);
                ColoredConsole.WriteLine("ToolsCss: ~W{0}~N", operaPatch.ToolsCss);
                ColoredConsole.WriteLine("FilterCss: ~W{0}~N", operaPatch.FilterCss);
                ColoredConsole.WriteLine();

                if (!ColoredConsole.Read("I would like to start patching: ", true))
                {
                    return(1);
                }

                ColoredConsole.WriteLine();

                operaPatch.Apply(settings, pakFileName);
                result = 0;
            }
            catch (Exception ex)
            {
                ColoredConsole.WriteLine();
                if (ex.InnerException == null)
                {
                    ColoredConsole.WriteLine("~r~WError:~k~R {0}~N", ex.Message);
                }
                else
                {
                    ColoredConsole.WriteLine("~r~WError:~k~R {0}~N ----> {1}", ex.Message, ex.InnerException.ToString());
                }
                result = 1;
            }
            return(result);
        }
Exemple #5
0
        public static int Main(string[] args)
        {
            int result;

            try
            {
                ColoredConsole.WriteLine("~WOpera Speed Dial Patch for {0}~N", OperaPatches.Patches[0].StartVersion);
                ColoredConsole.WriteLine("~WCopyright (c) 2013 dqdb~N");
                ColoredConsole.WriteLine();
                ColoredConsole.WriteLine("Thanks to ~WIzer0~N for all patches.");
                ColoredConsole.WriteLine();
                Settings settings = new Settings();
                settings.LoadFromConfigFile();
                settings.LoadFromConsole();
                settings.SaveToConfigFile();
                ColoredConsole.WriteLine();

                string pakFileName = FindLatestOperaPak(settings.OperaFolder);
                if (pakFileName == null)
                {
                    ColoredConsole.WriteLine("~r~WError:~k~R unable to find an ~r~Wopera.pak~N to patch.~N");
                    return(1);
                }

                OperaVersion version;

                try
                {
                    version = GetOperaPakVersion(pakFileName);
                }
                catch (Exception)
                {
                    ColoredConsole.WriteLine("~r~WError:~k~R unable to get version number from ~r~W{0}~k~R.~N", pakFileName);
                    return(1);
                }

                ColoredConsole.WriteLine("Opera version: ~W{0}~N", version);

                OperaPatch operaPatch = OperaPatches.Find(version);
                if (operaPatch == null)
                {
                    operaPatch = OperaPatches.FindWithHeuristics(settings, pakFileName);
                    if (operaPatch == null)
                    {
                        ColoredConsole.WriteLine();
                        ColoredConsole.WriteLine("~r~WError:~k~R this Opera version is not supported yet.~N");
                        return(1);
                    }

                    ColoredConsole.WriteLine();
                    ColoredConsole.WriteLine("Processing ...");
                    ColoredConsole.WriteLine();
                    ColoredConsole.WriteLine("OperaExeOffset: ~W0x{0:x8}~N", operaPatch.ExePatch.Offset);
                    ColoredConsole.WriteLine("SpeeddialLayoutJs: ~W{0}~N", operaPatch.SpeeddialLayoutJs);
                    ColoredConsole.WriteLine("StartPageHtml: ~W{0}~N", operaPatch.StartPageHtml);
                    ColoredConsole.WriteLine("PreinstalledSpeeddialsJs: ~W{0}~N", operaPatch.PreinstalledSpeeddialsJs);
                    ColoredConsole.WriteLine("SpeeddialSuggestionsJs: ~W{0}~N", operaPatch.SpeeddialSuggestionsJs);
                    ColoredConsole.WriteLine("ToolsCss: ~W{0}~N", operaPatch.ToolsCss);
                    ColoredConsole.WriteLine("FilterCss: ~W{0}~N", operaPatch.FilterCss);
                    ColoredConsole.WriteLine();

                    ColoredConsole.WriteLine("~y~KWarning:~k~Y this Opera version is probably supported, but it is ~y~KNOT~k~Y tested yet. Improper patching may have side effects.~N");
                    ColoredConsole.WriteLine();
                    if (!ColoredConsole.Read("I understand the risks: ", false))
                    {
                        return(1);
                    }
                    ColoredConsole.WriteLine();
                }
                else
                {
                    ColoredConsole.WriteLine("Using resource layout for Opera ~W{0}~N - ~W{1}~N builds.", operaPatch.StartVersion, operaPatch.EndVersion);
                    ColoredConsole.WriteLine();
                }

                if (!ColoredConsole.Read("I would like to start patching: ", true))
                {
                    return(1);
                }

                ColoredConsole.WriteLine();

                operaPatch.Apply(settings, pakFileName);
                result = 0;
            }
            catch (Exception ex)
            {
                ColoredConsole.WriteLine();
                if (ex.InnerException == null)
                {
                    ColoredConsole.WriteLine("~r~WError:~k~R {0}~N", ex.Message);
                }
                else
                {
                    ColoredConsole.WriteLine("~r~WError:~k~R {0}~N ----> {1}", ex.Message, ex.InnerException.ToString());
                }
                result = 1;
            }
            return(result);
        }