我可以为桌面和移动设备制作一个简单的浏览器插件吗?
Can I make a simple browser plugin for both desktop and mobile?
我想使用 Chrome 但看起来 Chrome 对于 Android 不能 运行 扩展? Firefox 的支持似乎不稳定。
我只想为特定域请求和执行远程 CSS 和 JS 文件。我不需要任何 UI 或任何东西。
不确定我是应该继续使用 Firefox 还是考虑推出我自己的 'browser' 并嵌入插件?
您可以使用此处提供的 Firefox SDK:https://developer.mozilla.org/en-US/Add-ons/SDK
它允许您针对两个平台进行开发。如果您在 android 的 Firefox 中遇到 sdk 问题,您可以阅读以下内容:https://developer.mozilla.org/en-US/Firefox_for_Android
如果不需要UI,设置起来会很容易:)
关于post中的评论,我制作了一个用于设置开发中扩展的脚本:
# Run this script from your project base dir.
#1 - Complete the following vars:
#ANDROID_APP_ID=org.mozilla.fennec;
ANDROID_APP_ID=org.mozilla.firefox_beta;
#ANDROID_APP_ID=org.mozilla.firefox;
APP_NAME="YourExtensionName";
OUTPUT_DIR=$HOME/Bureau;
FILES="./";
EXCLUDE="-xr!./.git";
CLEAN_APP_DATA=false;
#2 - This will clear all your app cache
if [ "$CLEAN_APP_DATA" == "true" ]; then
adb shell pm clear $ANDROID_APP_ID
fi
#3 - This will create the XPI file
7z a -r $OUTPUT_DIR/$APP_NAME.xpi $FILES $EXCLUDE;
#4 - This will copy the XPI to the phone SD card. Don't worry if you don't have SD card, it will be copied to a directory called /sdcard
adb push $OUTPUT_DIR/$APP_NAME.xpi /sdcard/$APP_NAME.xpi;
#5 - This will start the Firefox App with the XPI to install
adb shell am start -a android.intent.action.VIEW -c android.intent.category.DEFAULT -d file:///mnt/sdcard/$APP_NAME.xpi -n $ANDROID_APP_ID/.App;
#6 - Redirect tcp to watch via console
#adb forward tcp:6000 tcp:6000; #For Firefox for Android 34 and earlier
adb forward tcp:6000 localfilesystem:/data/data/$ANDROID_APP_ID/firefox-debugger-socket #For Firefox for Android 35 and later
#7 - This will wait to you to test your addon and press any key to close Firefox.
echo ""; read -p "Press 'r' to restart or any other key to close the browser..." pressedKey;
if [ "$pressedKey" == "r" ]; then
adb shell am force-stop $ANDROID_APP_ID;
#8 - This will remove the XPI from the filesystem (but it's still copied on your Firefox)
adb shell rm /sdcard/$APP_NAME.xpi
rm $OUTPUT_DIR/$APP_NAME.xpi;
echo "Firefox has been forced to stop. Restarting...";
adb shell am start -a android.intent.action.VIEW -c android.intent.category.DEFAULT -n $ANDROID_APP_ID/.App;
echo ""; read -p "Test your addon on mobile. Press any key to close app...";
fi
adb shell am force-stop $ANDROID_APP_ID;
adb shell rm /sdcard/$APP_NAME.xpi
rm $OUTPUT_DIR/$APP_NAME.xpi;
exit 0;
我想使用 Chrome 但看起来 Chrome 对于 Android 不能 运行 扩展? Firefox 的支持似乎不稳定。
我只想为特定域请求和执行远程 CSS 和 JS 文件。我不需要任何 UI 或任何东西。
不确定我是应该继续使用 Firefox 还是考虑推出我自己的 'browser' 并嵌入插件?
您可以使用此处提供的 Firefox SDK:https://developer.mozilla.org/en-US/Add-ons/SDK
它允许您针对两个平台进行开发。如果您在 android 的 Firefox 中遇到 sdk 问题,您可以阅读以下内容:https://developer.mozilla.org/en-US/Firefox_for_Android
如果不需要UI,设置起来会很容易:)
关于post中的评论,我制作了一个用于设置开发中扩展的脚本:
# Run this script from your project base dir.
#1 - Complete the following vars:
#ANDROID_APP_ID=org.mozilla.fennec;
ANDROID_APP_ID=org.mozilla.firefox_beta;
#ANDROID_APP_ID=org.mozilla.firefox;
APP_NAME="YourExtensionName";
OUTPUT_DIR=$HOME/Bureau;
FILES="./";
EXCLUDE="-xr!./.git";
CLEAN_APP_DATA=false;
#2 - This will clear all your app cache
if [ "$CLEAN_APP_DATA" == "true" ]; then
adb shell pm clear $ANDROID_APP_ID
fi
#3 - This will create the XPI file
7z a -r $OUTPUT_DIR/$APP_NAME.xpi $FILES $EXCLUDE;
#4 - This will copy the XPI to the phone SD card. Don't worry if you don't have SD card, it will be copied to a directory called /sdcard
adb push $OUTPUT_DIR/$APP_NAME.xpi /sdcard/$APP_NAME.xpi;
#5 - This will start the Firefox App with the XPI to install
adb shell am start -a android.intent.action.VIEW -c android.intent.category.DEFAULT -d file:///mnt/sdcard/$APP_NAME.xpi -n $ANDROID_APP_ID/.App;
#6 - Redirect tcp to watch via console
#adb forward tcp:6000 tcp:6000; #For Firefox for Android 34 and earlier
adb forward tcp:6000 localfilesystem:/data/data/$ANDROID_APP_ID/firefox-debugger-socket #For Firefox for Android 35 and later
#7 - This will wait to you to test your addon and press any key to close Firefox.
echo ""; read -p "Press 'r' to restart or any other key to close the browser..." pressedKey;
if [ "$pressedKey" == "r" ]; then
adb shell am force-stop $ANDROID_APP_ID;
#8 - This will remove the XPI from the filesystem (but it's still copied on your Firefox)
adb shell rm /sdcard/$APP_NAME.xpi
rm $OUTPUT_DIR/$APP_NAME.xpi;
echo "Firefox has been forced to stop. Restarting...";
adb shell am start -a android.intent.action.VIEW -c android.intent.category.DEFAULT -n $ANDROID_APP_ID/.App;
echo ""; read -p "Test your addon on mobile. Press any key to close app...";
fi
adb shell am force-stop $ANDROID_APP_ID;
adb shell rm /sdcard/$APP_NAME.xpi
rm $OUTPUT_DIR/$APP_NAME.xpi;
exit 0;