Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@codebrew/capacitor-user-agent

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codebrew/capacitor-user-agent - npm Package Compare versions

Comparing version
0.0.5
to
0.0.6
+43
android/src/main/j...or/plugins/useragent/UserAgentPlugin.kt
package codebrew.capacitor.plugins.useragent;
import android.webkit.WebSettings
import com.getcapacitor.JSObject
import com.getcapacitor.Plugin
import com.getcapacitor.PluginCall
import com.getcapacitor.PluginMethod
import com.getcapacitor.annotation.CapacitorPlugin
@CapacitorPlugin(name = "UserAgent")
class UserAgentPlugin : Plugin() {
private var settings: WebSettings? = null
override fun load() {
settings = bridge.webView.settings
}
@PluginMethod
fun get(call: PluginCall) {
val ret = JSObject()
val userAgent = settings?.userAgentString
ret.put("userAgent", userAgent)
call.resolve(ret)
}
@PluginMethod
fun set(call: PluginCall) {
val value = call.getString("userAgent", null)
settings?.userAgentString = value
val ret = JSObject()
ret.put("userAgent", settings?.userAgentString)
call.resolve(ret)
}
@PluginMethod
fun reset(call: PluginCall) {
settings!!.userAgentString = null
val ret = JSObject()
call.resolve()
}
}
+4
-0

@@ -9,2 +9,3 @@ ext {

buildscript {
ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '1.8.21'
repositories {

@@ -16,2 +17,3 @@ google()

classpath 'com.android.tools.build:gradle:8.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

@@ -62,2 +64,4 @@ }

androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation "androidx.core:core-ktx:1.10.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
+1
-1
{
"name": "@codebrew/capacitor-user-agent",
"version": "0.0.5",
"version": "0.0.6",
"description": "User Agent get/set/reset plugin for Capacitor",

@@ -5,0 +5,0 @@ "main": "dist/plugin.cjs.js",

package codebrew.capacitor.plugins.useragent;
import android.webkit.WebSettings;
import com.getcapacitor.JSObject;
import com.getcapacitor.Plugin;
import com.getcapacitor.PluginCall;
import com.getcapacitor.PluginMethod;
import com.getcapacitor.annotation.CapacitorPlugin;
@CapacitorPlugin(name = "UserAgent")
public class UserAgentPlugin extends Plugin {
private WebSettings settings;
@Override
public void load() {
settings = bridge.getWebView().getSettings();
}
@PluginMethod
public void get(PluginCall call) {
JSObject ret = new JSObject();
String userAgent = settings.getUserAgentString();
ret.put("userAgent", userAgent);
call.resolve(ret);
}
@PluginMethod(returnType = PluginMethod.RETURN_NONE)
public void set(PluginCall call) {
String ua = call.getString("userAgent", null);
settings.setUserAgentString(ua);
call.resolve();
}
@PluginMethod(returnType = PluginMethod.RETURN_NONE)
public void reset(PluginCall call) {
settings.setUserAgentString(null);
call.resolve();
}
}