我有一个index.html调用外部 URL的页面。这个外部 URL 是一个 JSON 端点。换句话说,当我打开开发工具(使用F12)时,我看到两个资源:index.html和myJSONEndpoint。
我希望每次加载时都能获取该 JSONindex.html并对其进行处理。
Greasemonkey 或 Tampermonkey 能做到这一点吗?
页面示例:
<!doctype html>
<html>
<head>
<title>Weather</title>
<script>
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myObj = JSON.parse(this.responseText);
}
};
xmlhttp.open("GET", "https://api.weather.gov/points/39.7456,-97.0892", true);
xmlhttp.send();
</script>
</head>
<body>
<p>Page Loaded...</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当我加载该页面时,开发工具中会出现两个请求。基本索引页面和 JSON 请求。
我想获取 JSON 内容并将其推送到 DOM 上。然后用户可以从那里复制/粘贴。
创建一个新的<div>然后将内容粘贴在那里?
我在运行部署时看到以下错误:
Error from server (NotFound): error when creating "n3deployment.yaml": namespaces "n2" not found
我的 n3deployment.yaml 没有提到 n2?
一步步
c:\temp\k8s>kubectl get pods
No resources found.
c:\temp\k8s>kubectl get svc
No resources found.
c:\temp\k8s>kubectl get deployments
No resources found.
c:\temp\k8s>kubectl get namespaces
NAME STATUS AGE
default Active 20h
docker Active 20h
kube-public Active 20h
kube-system Active 20h
Run Code Online (Sandbox Code Playgroud)
n3namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
name: n3
n3service.yaml
apiVersion: v1
kind: Service
metadata:
name: my-app-n3
namespace: n3
labels:
app: my-app-n3
spec:
type: LoadBalancer …Run Code Online (Sandbox Code Playgroud) 我希望在 CloudFormation 模板末尾调用 REST API 端点。
PUT https://example.com/v1/endpoint
{
// Body Content
}
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点?我能想到的唯一办法是:
上面的方法看起来非常混乱并且比必要的花费更多的精力。
greasemonkey ×1
javascript ×1
json ×1
kubernetes ×1
minikube ×1
namespaces ×1
rest ×1
tampermonkey ×1
userscripts ×1