diff --git a/main.go b/main.go index e2bbf1f..84fea41 100755 --- a/main.go +++ b/main.go @@ -172,6 +172,8 @@ func applyPatch(patchPath, rootPath string) error { return applyNewModifications(outputFilePath, modifications) case "copy": return applyCopyPatch(inputFilePath, outputFilePath) + case "marker": + return applyMarkerPatch(outputFilePath, modifications) default: fmt.Printf("Type not specified defaulting to standard") return applyStandardModifications(outputFilePath, modifications) diff --git a/marker.go b/marker.go new file mode 100644 index 0000000..39769c1 --- /dev/null +++ b/marker.go @@ -0,0 +1,81 @@ +package main + +import ( + "fmt" + "os" + "strings" +) + +func applyMarkerPatch(targetFilePath string, modifications []string) error { + // Parse patch content + var marker string + var entriesToAdd []string + var entriesToRemove []string + collecting := false + + for _, line := range modifications { + switch { + case strings.HasPrefix(line, "#"): + // Capture marker line (first # line only) + if marker == "" { + marker = strings.TrimSpace(strings.TrimPrefix(line, "#")) + collecting = true + } + case collecting && strings.HasPrefix(line, "+"): + entriesToAdd = append(entriesToAdd, strings.TrimPrefix(line, "+")) + case collecting && strings.HasPrefix(line, "-"): + entriesToRemove = append(entriesToRemove, strings.TrimPrefix(line, "-")) + } + } + + // Validate input + if marker == "" { + return fmt.Errorf("missing marker line starting with #") + } + + // Read entire file + content, err := os.ReadFile(targetFilePath) + if err != nil { + return fmt.Errorf("failed to read file: %v", err) + } + + lines := strings.Split(string(content), "\n") + var modifiedLines []string + markerFound := false + + for _, line := range lines { + // Check if current line is our marker + if !markerFound && strings.TrimSpace(line) == marker { + markerFound = true + modifiedLines = append(modifiedLines, line) + // Add new entries immediately after marker + modifiedLines = append(modifiedLines, entriesToAdd...) + continue + } + + // Check if line should be removed + keep := true + for _, removeLine := range entriesToRemove { + if line == removeLine { + keep = false + break + } + } + + if keep { + modifiedLines = append(modifiedLines, line) + } + } + + if !markerFound { + return fmt.Errorf("marker line not found: %q", marker) + } + + // Write directly to target file + err = os.WriteFile(targetFilePath, []byte(strings.Join(modifiedLines, "\n")), 0644) + if err != nil { + return fmt.Errorf("failed to write changes: %v", err) + } + + return nil +} diff --git a/pre-compile-patches/about-store-2.patch b/pre-compile-patches/about-store-2.patch new file mode 100644 index 0000000..c0c4578 --- /dev/null +++ b/pre-compile-patches/about-store-2.patch @@ -0,0 +1,6 @@ +t: add +i: /browser/components/about/components.conf +o: /browser/components/about/components.conf + +# 'settings', ++ 'store', \ No newline at end of file diff --git a/pre-compile-patches/about-store.patch b/pre-compile-patches/about-store.patch new file mode 100644 index 0000000..054d68c --- /dev/null +++ b/pre-compile-patches/about-store.patch @@ -0,0 +1,9 @@ +t: add +i: /browser/components/about/AboutRedirector.cpp +o: /browser/components/about/AboutRedirector.cpp + +#static const RedirEntry kRedirMap[] = { ++ {"store", "http://localhost:20351/", ++ nsIAboutModule::ALLOW_SCRIPT | ++ nsIAboutModule::URI_MUST_LOAD_IN_CHILD | ++ nsIAboutModule::URI_CAN_LOAD_IN_PRIVILEGEDABOUT_PROCESS}, // chrome://browser/content/aboutStore.xhtml \ No newline at end of file