雄壮的奥特曼 发表于 2023-2-9 21:31:22

哥哥们请问一下如何使用油猴拿到指定名称的cookie😿

网址:https://www.clarins.com.cn/

油猴脚本:

!(data/attachment/forum/202302/09/212815ogt5t6t395x4z9zd.png)

目的:
    hook住这里的会话cookie
      !(data/attachment/forum/202302/09/212951jpp56pf5zhifp5pp.png)

抱拳了

steven026 发表于 2023-2-9 21:31:23

!(data/attachment/forum/202302/10/091016zwesxsye36he6n2y.png)
```js
// ==UserScript==
// @name         Hook Cookie
// @namespace    http://tampermonkey.net/
// @version      0.1
// @descriptiontry to take over the world!
// @author       You
// @match      https://www.clarins.com.cn/
// @icon         http://clarins.com.cn/favicon.ico
// @grant      none
// @run-at       document-start
// ==/UserScript==

let cookieTemp='';
Object.defineProperty(document,'cookie',{
    set:(newValue)=>{
      console.log('Hook cookie set -->',newValue)

      if(newValue.includes('TCSESSION')){
            debugger
      }

      return (cookieTemp=newValue)
    },
    get:()=>cookieTemp
})
```

我觉得你可能是没加`// @run-at       document-start`提前脚本运行的时机
cookie一般设置的比较早,如果不加通常劫持不到

李恒道 发表于 2023-2-9 22:38:09

不太理解目的是什么...
卡在哪里了

雄壮的奥特曼 发表于 2023-2-10 19:11:14

steven026 发表于 2023-2-10 09:11
!(data/attachment/forum/202302/10/091016zwesxsye36he6n2y.png)
```js
// ==UserScript==


哈哈哈哈哈无论咋说都得谢谢你了哥哥 问题我自己解决了!

雄壮的奥特曼 发表于 2023-2-10 19:12:45

李恒道 发表于 2023-2-9 22:38
不太理解目的是什么...
卡在哪里了

目的就是获得那个名叫tesession的cookie嘛
页: [1]
查看完整版本: 哥哥们请问一下如何使用油猴拿到指定名称的cookie?