尽管需要进行建议的更改,但 Chrome 扩展程序被拒绝

问题描述

我有一个 chrome 扩展被拒绝,因为根据他们的说法,我不需要我要求的选项卡权限。但是,我查看了我的代码,如果没有它,我的 chrome 扩展将无法工作。我什至在未经许可的情况下尝试了我的 chrome 扩展程序,但失败了。我在执行 chrome.tabs.onRemoved.addListener(function(tabid,removeInfo)chrome.tabs.query({active: true,currentwindow: true}、function(tabs) 等操作时使用标签,这些都需要标签权限。有人可以帮助我理解为什么它可能会被拒绝吗?或者如果有解决办法。

有趣的是,我使用 tabs 权限的原始扩展被接受了,但是当我发送修订版时,他们拒绝了,尽管这些更改与 tabs 无关。

我得到的具体推理:

Violation reference ID: Purple Potassium
Violation: The following permission(s) need not be requested for the methods/properties implemented by the item:
tabs
How to rectify: Remove the above permission(s). The properties used by the items will continue to function even without requesting these permissions.

当我在没有 tabs 权限的情况下运行我的 chrome 扩展时,我的 background.js 包含一些 chrome.tabs 代码会抛出这个错误。如果我重新添加权限,它就会得到解决

Error handling response: TypeError: Error in invocation of tabs.sendMessage(integer tabId,any message,optional object options,optional function responseCallback): No matching signature.
    at <URL>

引发该错误代码块如下。

chrome.tabs.query({active: true,currentwindow: true},function(tabs) {
            chrome.tabs.sendMessage(tabId,{method: "getNumber"},function(response) {
                console.log(response);
                currentNumber = response.current;
            });
        });

编辑:

背景.js

var tabId = "";
var running = 0;
chrome.runtime.onMessage.addListener(function(msg,sender,sendResponse) {
    if (msg.text == "what is my tab_id?") {
        tabId = sender.tab.id;
        sendResponse({tab: sender.tab.id});
    }
});

chrome.tabs.onRemoved.addListener(function(tabid,removeInfo) {
    if(tabid == tabId) {
        console.log("closed tab");
        stop();
    }
});

function stop() {
    chrome.storage.sync.set({"monitor": 0},function() {
    });
    running = 1;
}

function start() {
    chrome.storage.sync.set({"monitor": 1},function() {
    });
    running = 0;
}

function sendSMS(phone_number) {
    var currentNumber = 100000000;
    var timetoPurchase = 0;
    var prevNumber = currentNumber;
    var increase = 0;
    var dropStat = 0;
    var inst = setInterval(function() {
        chrome.storage.sync.get('increment',function(data) {
            increase = data.increment;
        });

        chrome.tabs.query({active: true,function(response) {
                console.log(response);
                currentNumber = response.current;
                lastUpdated = response.lastUp;
                timetoPurchase = response.done;
                dropStat = response.dropStatus;
            });
        });
        if(running == 1) {
            clearInterval(inst);
            return;
        }
        //more logic below to make some api calls

    },5000);
}

Contentscript.js

chrome.runtime.onMessage.addListener(
    function(request,sendResponse) {
        if (request.method == "getNumber") {
            sendResponse({current: 0,lastUp : "time value here",done : 0,dropStatus : 0})
            return true;
        }
        return true;
});

chrome.runtime.sendMessage({ text: "what is my tab_id?" },tabId => {
    console.log('My tabId is',tabId);
 });

在 popup.html 上按下按钮时调用函数 sendSMS

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...