Repository: huhu/rust-search-extension (language: rust)

Issue:
Remove or make optional enhancement to rust-lang repository's release page
I have been using the extension for a while, it's amazingly useful. Thanks for the effort you put into it.

Unfortunately I had to disable the extension because it's become too high of a security risk for me. Giving away read capabilities to a critical website such as Github for a small enhancement is not worth it IMO.

I know that this is something that many users face and had to pass on the extension because of this. I see couple of solutions:
- make the feature optional and request permissions on-demand
- remove the feature entirely because it overlaps with the new features provided by the Github UI: you can already open a *searchable* outline of any markdown file

Speaking for myself, I never even used the feature.


Discussion / hints:
Fair enough. I'll remove this feature in the next version. Thanks for the feedback.

Fix patch:
diff --git a/extension/main.js b/extension/main.js
index ee4b951c..dda156d3 100644
--- a/extension/main.js
+++ b/extension/main.js
@@ -345,21 +345,6 @@ function getPlatformOs() {
         },
     });
 
-    // Search previous Rust version
-    omnibox.addRegexQueryEvent(/^v?1\.\d*/i, {
-        onSearch: (query) => {
-            let [_, minor] = query.split('.');
-            return getReleasedVersions()
-                .filter(v => !minor || `${v.minor}`.startsWith(minor))
-                .map(version => {
-                    return {
-                        content: `${RUST_RELEASE_README_URL}?version=${version.number}`,
-                        description: `Rust ${c.match(version.number)} - ${c.dim(c.normalizeDate(version.date))}`,
-                    }
-                });
-        },
-    });
-
     omnibox.addRegexQueryEvent(/^`?e\d{2,4}`?$/i, {
         onSearch: (query) => {
             query = query.replace("`", "");
diff --git a/extension/script/github.css b/extension/script/github.css
deleted file mode 100644
index 20019b14..00000000
--- a/extension/script/github.css
+++ /dev/null
@@ -1,43 +0,0 @@
-.rse-version-list-item {
-    padding: 0.5rem 1rem;
-    border-left: solid transparent 2px;
-}
-
-.rse-version-list-item:not(:last-child) {
-    border-bottom: 1px solid var(--color-border-muted);
-}
-
-.rse-version-date {
-    margin: auto 0 auto auto;
-}
-
-.rse-version-list-gap {
-    padding: 0.2rem;
-    text-align: center;
-    font-size: 16px;
-    font-weight: bold;
-    margin: 0.3rem 0;
-}
-
-.rse-active {
-    border-left: solid #f9826c 2px;
-}
-
-@media screen and (min-width: 1280px) {
-    .rse-version-list {
-        box-sizing: content-box;
-        min-width: 200px;
-        border-left: var(--color-border-muted) solid 1px;
-        margin-left: 1.5rem;
-        max-height: 100vh;
-        position: sticky;
-        /* 90px to fix compatibility of Github markdown file's sticky header*/
-        top: 90px;
-        overflow: scroll !important;
-        font-size: 13px;
-        list-style: none;
-        color: var(--color-text-primary);
-        background-color: var(--color-bg-canvas);
-        z-index: 999;
-    }
-}
\ No newline at end of file
diff --git a/extension/script/rust-lang-release.js b/extension/script/rust-lang-release.js
deleted file mode 100644
index 204666b8..00000000
--- a/extension/script/rust-lang-release.js
+++ /dev/null
@@ -1,144 +0,0 @@
-window.onload = () => {
-    let searchParams = new URL(location.href).searchParams;
-    let toVersion = searchParams.get("version");
-    // Parse search parameter to scroll target version
-    // E.g: https://github.com/rust-lang/rust/blob/master/RELEASES.md?version=1.43.0 will scroll to version 1.43.0
-    if (toVersion) {
-        scrollToVersion(toVersion);
-    }
-
-    let versions = [];
-    for (let title of document.querySelectorAll('.markdown-body>h1')) {
-        let version = parseVersion(title)
-        versions.push(version);
-    }
-
-    let ul = document.createElement("ul");
-    ul.classList.add("rse-version-list");
-    let year = new Date().getFullYear();
-    versions.filter(version => version.fix === "0" && version.major === "1").forEach(version => {
-        let item = document.createElement("li");
-        item.classList.add("rse-version-list-item");
-
-        let html = `<div style="display: flex">
-                        <a href="${version.anchor}"><b>${version.number}</b></a> 
-                        <span class="rse-version-date Counter">${version.date}</span>
-                    </div>`;
-        let fixVersions = versions
-            .filter(v => v.minor === version.minor && v.major === version.major && v.fix !== "0")
-            .sort((a, b) => parseInt(a.fix) - parseInt(b.fix));
-        if (fixVersions?.length > 0) {
-            fixVersions = fixVersions.map(fv => `<a href="${fv.anchor}"><small>${fv.number}</small></a>`).join(" , ");
-            html += `<div style="margin-top: 0.3rem">${fixVersions}</div>`;
-        }
-
-        item.innerHTML = html;
-        let versionYear = new Date(version.date).getFullYear();
-        if (versionYear < year) {
-            // Show year gap
-            year = versionYear;
-            let li = document.createElement("li");
-            li.classList.add("rse-version-list-gap");
-            li.textContent = year;
-            ul.appendChild(li);
-        }
-        ul.appendChild(item);
-    });
-
-    let markdownBody = document.querySelector("article.markdown-body");
-    let readme = markdownBody.parentElement;
-    readme.setAttribute("style", "display: flex; padding-right: 0px !important");
-    readme.appendChild(ul);
-
-    setTimeout(() => {
-        fixStickyNotWorking();
-        fixGithubTocCompatibility();
-    });
-
-    highlight();
-};
-
-// https://michaelmovsesov.com/articles/fix-css-position-sticky-not-working
-function fixStickyNotWorking() {
-    let parent = document.querySelector('.rse-version-list').parentElement;
-
-    while (parent) {
-        const overflow = getComputedStyle(parent).overflow;
-        if (overflow !== 'visible') {
-            break;
-        }
-        parent = parent.parentElement;
-    }
-
-    if (parent) {
-        parent.setAttribute("style", "position:relative; z-index:0; overflow: visible");
-    }
-}
-
-// https://web.dev/resize-observer/
-function fixGithubTocCompatibility() {
-    let tocStickyHeader = document.querySelector("#repos-sticky-header");
-    if (tocStickyHeader) {
-        let toc = document.querySelector('.rse-version-list');
-        const observer = new ResizeObserver(entries => {
-            for (let entry of entries) {
-                // Hide our TOC if we have no enough space.
-                if (entry.contentRect.width <= 1040) {
-                    toc.style.display = "none";
-                } else {
-                    toc.style.display = "block";
-                }
-            }
-        });
-        observer.observe(tocStickyHeader);
-    }
-}
-
-function scrollToVersion(version) {
-    let versionElements = Array.from(document.querySelectorAll('.markdown-body>h1'));
-    let target = versionElements.find(h1 => h1.textContent.toLowerCase().includes(version.toLowerCase()));
-    if (target) {
-        location.href = target.firstElementChild.href;
-    }
-}
-
-function highlight() {
-    let items = document.querySelectorAll('.markdown-body>h1>a');
-    const scrollHandler = entries => {
-        // Find the first entry which intersecting and ratio > 0.9 to highlight.
-        let entry = entries.find(entry => {
-            return entry.isIntersecting && entry.intersectionRatio > 0.9;
-        });
-        if (!entry) return;
-
-        document.querySelectorAll(".rse-version-list-item").forEach((item) => {
-            item.classList.remove("rse-active");
-        });
-
-        let url = new URL(entry.target.href);
-        let link = document.querySelector(`.rse-version-list-item a[href$="${url.hash}"]`)
-        if (link) {
-            let target = link.parentElement.parentElement;
-            target.classList.add("rse-active");
-            target.scrollIntoView({ behavior: "auto", block: "nearest" });
-        }
-    };
-    const observer = new IntersectionObserver(scrollHandler, { threshold: 1 });
-    items.forEach(item => observer.observe(item));
-}
-
-function parseVersion(title) {
-    let text = title.textContent;
-    let anchor = title.firstElementChild.getAttribute("href");
-    let [number, date] = text.toLowerCase().replace(/version|\(|\)/ig, "").trim().split(" ");
-    let [major, minor, ...fix] = number.split(".");
-    fix = fix.join(".");
-    return {
-        number,
-        date,
-        major,
-        minor,
-        fix,
-        anchor,
-    }
-}
\ No newline at end of file
diff --git a/manifest.jsonnet b/manifest.jsonnet
index 67f6fed2..a6808d94 100644
--- a/manifest.jsonnet
+++ b/manifest.jsonnet
@@ -71,10 +71,6 @@ json.addIcons(icons())
   matches=['*://rust.extension.sh/update'],
   js=INDEX_MANAGER_FILES + utils.js_files('script', ['rust-extension-sh']),
   css=[],
-).addContentScript(
-  matches=['*://github.com/rust-lang/rust/blob/master/RELEASES.md*'],
-  js=utils.js_files('script', ['lib', 'rust-lang-release']),
-  css=['script/github.css'],
 ).addContentScript(
   matches=[
     '*://docs.rs/*',


Test patch: