小编A. *_*ner的帖子

Tampermonkey 访问页面上的 JSON 调用/URL?

我有一个index.html调用外部 URL的页面。这个外部 URL 是一个 JSON 端点。换句话说,当我打开开发工具(使用F12)时,我看到两个资源:index.htmlmyJSONEndpoint

我希望每次加载时都能获取该 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>然后将内容粘贴在那里?

javascript json greasemonkey userscripts tampermonkey

6
推荐指数
1
解决办法
9911
查看次数

未找到命名空间

我在运行部署时看到以下错误:

Error from server (NotFound): error when creating "n3deployment.yaml": namespaces "n2" not found

我的 n3deployment.yaml 没有提到 n2?

一步步

  1. 确保一切都是空的
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)
  1. 创建文件
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)

namespaces kubernetes minikube

5
推荐指数
2
解决办法
1万
查看次数

从 CloudFormation 调用 API/Web 请求

我希望在 CloudFormation 模板末尾调用 REST API 端点。

PUT https://example.com/v1/endpoint
{
  // Body Content
}
Run Code Online (Sandbox Code Playgroud)

有没有办法做到这一点?我能想到的唯一办法是:

  1. 创建 lambda 函数
  2. 使用 CF 执行 lambda 函数
  3. 删除lamdba函数

上面的方法看起来非常混乱并且比必要的花费更多的精力。

rest amazon-web-services aws-cloudformation

2
推荐指数
1
解决办法
2284
查看次数