Obtaining Chrome Extension ID for development

前端 未结 3 600
春和景丽
春和景丽 2020-11-22 12:03

Although similar to this SO question, I am not asking:

Under what conditions does an extension\'s ID change?

nor

3条回答
  •  萌比男神i
    2020-11-22 12:49

    Unpacked Chrome extensions ID is generated based on the path of it's directory. For unpacked extension you can generate the id in following way (code in Python):

    import hashlib
    
    m = hashlib.sha256()
    m.update(bytes(PATH.encode('utf-8')))
    EXTID = ''.join([chr(int(i, base=16) + ord('a')) for i in m.hexdigest()][:32])
    

    where PATH is normalized path to the extension, ie.:

    PATH = os.path.dirname(os.path.realpath(__file__))
    

提交回复
热议问题