Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Prevent script Collision

オープン
#780 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
javascript, typescript
領域
frontend

調査の方向性

まず、issue で報告されている chrome.scripting.executeScript の使用と Stacks.showModal の呼び出しを、リンクされている Stack Apps の議論と併せて確認します。要求されているスクリプトの分離または衝突回避の動作が Stacks 内で実現可能かどうかを判断します。完了とするには、合意されたスコープと、既存のページ動作を壊さない、文書化された動作するアプローチが必要です。

索引モデルが issue の本文から書いたものです。

説明

Is your feature request related to a problem? Please describe.
Yes, I am developing an extension to be used on SE websites and I was thinking of using the existing methods, but there is a privacy policy problem.
so the other way is to implement the following:

chrome.scripting.executeScript({
    target: { tabId: tabId, allFrames: true },
    files: ['src/js/stacks.min.js'],
});

the problem is that when it is executed overwrites some events: such as the filtering of posts.

Describe the solution you'd like
I thought that Stack could offer some kind of implementation to support the extensions that implement it; or avoid the script collision with it, through some method like jquery does:

https://api.jquery.com/jquery.noconflict/

Describe alternatives you've considered
I have no alternative; I have put everything documented in this post on the stack apps site but the solutions they have offered me have not worked.

https://stackapps.com/questions/9205/extension-access-to-layout-and-javascript-of-stackexchange-network-site-instead

Additional context
I do not know if this topic has already been touched, or if there is a solution that I have not found yet.

in the structure of the extension this document.js that is supposed to be executed next to the user's active tab, well I have this:

let atsu_btn = `
                                    <button 
                                    type="button" 
                                    class="s-btn js-modal-open" 
                                    id="atsu-post-comment"
                                    data-togle="s-modal"
                                    data-target="#atsu-modal"
                                    style="margin-top:5px; border: 3px solid rgb(246, 178, 107); color: rgb(194, 123, 160); font-style: italic;">
                                    Auto Com. &amp; Help
                                    </button>
                    
                    
                                    <div data-controller="s-modal" data-s-modal-return-element="#atsu-post-comment">
                                        <aside class="s-modal" id="atsu-modal" tabindex="-1" role="dialog" aria-labelledby="modal-title" aria-describedby="modal-description" aria-hidden="true" data-controller="s-modal" data-s-modal-target="modal" data-s-modal-return-element=".js-modal-open[data-target='#atsu-modal']" data-s-modal-remove-when-hidden="false" data-joder="1">
                                            <div class="s-modal--dialog wmn8 hmn5" role="document">
                                                <h1 class="s-modal--header" id="modal-title">Selection and Configuration Automatic Comments.</h1>
                                                <div class="s-modal--body hs5" id="modal-description">

                                                    <nav>
                                                        <ul class="s-navigation" role="tablist" data-controller="s-navigation-tablist">
                                                            <li>
                                                                <button type="button"
                                                                        role="tab"
                                                                        id="tab-question"
                                                                        aria-selected="true"
                                                                        aria-controls="panel-question"
                                                                        class="s-navigation--item is-selected">Comments for Questions</button>
                                                            </li>
                                                            <li>
                                                                <button type="button"
                                                                        role="tab"
                                                                        id="tab-answers"
                                                                        aria-selected="false"
                                                                        aria-controls="panel-answers"
                                                                        tabindex="-1"
                                                                        class="s-navigation--item">Comments for Answers</button>
                                                            </li>
                                                            <li>
                                                                <button type="button"
                                                                        role="tab"
                                                                        id="tab-comment-setting"
                                                                        aria-selected="false"
                                                                        aria-controls="panel-comment-setting"
                                                                        tabindex="-1"
                                                                        class="s-navigation--item">Setting</button>
                                                            </li>
                                                        </ul>
                                                    </nav>
                                                    
                                                    <div id="panel-question" aria-labelledby="tab-question" class="d-flex hs5">
                                                        Comments for question.

                                                    </div>
                                                    
                                                    <div id="panel-answers" aria-labelledby="tab-answers" class="d-none d-flex hs5">
                                                        Comments for Answers
                                                    </div>
                                                    <div id="panel-comment-setting" aria-labelledby="tab-comment-setting" class="d-none d-flex hs5">

                                                        <div class="d-flex flex--item gs8 gsx as-end">
                                                            <button class="flex--item s-btn s-btn__primary" type="button">Save Setting ATSU</button>
                                                            <button class="flex--item s-btn" type="button" data-action="s-modal#hide">Cancel</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </aside>    
                                    </div>
                                    `;

when inserting it, the button does not work, although its attributes are adequate to open the mode, i implement:

document.querySelector("#atsu-post-comment").addEventListener("click", function (e) {
                    Stacks.showModal(document.querySelector("#atsu-modal"));
});

which returns the error:

image

to avoid this error then it was tried to implement:

let scriptInserted = document.createElement('script')
scriptInserted.innerHTML='Stacks.showModal(document.querySelector("#atsu-modal"))';
console.log(scriptInserted);
document.body.appendChild(scriptInserted);

Causing the following error:

image

To mitigate this last error, an attempt was made to implement chrome.scripting.executeScript but even though it works; this has collisions with its original version that comes on the page, to which there is no access due to security policies.

主要言語
TypeScript
スター
672
フォーク
107
平均マージ
2日 12時間
マージ済み PR(30日)
26

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

StackExchange/Stacks のほかの issue

StackExchange/Stacks の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。